C Program To Print The ID, Name & Marks Of Each Student Using Struct


♣ Try it Out ::
#include<stdio.h>
#include<conio.h>

struct student
{
    int id;
    char name[32];
    int m1, m2, m3;
};

int main()
{
    struct student s[100];

    int i, TS;

    printf("Homw many students? "); scanf("%d", &TS);
    printf("Enter id, name & 3 marks of %d students: \n", TS);

    for(i=0; i<TS; i++)
    {
        scanf("%d", &s[i].id);
        scanf("%s", s[i].name);
        scanf("%d%d%d", &s[i].m1, &s[i].m2, &s[i].m3);
    }

    for(i=0; i<TS; i++)
    {
        int TotalMarks = s[i].m1 + s[i].m2 + s[i].m3;

        printf("\nStudent id\t: %d \n", s[i].id);
        printf("Student name\t: %s \n", s[i].name);
        printf("Total marks\t: %d \n\n", TotalMarks);
    }

    getch();
    return(0);
}

♣ Output ::
Homw many students? 3
Enter id, name & 3 marks of 3 students:
1002020001 Muhit 80 85 90
1002020002 Raju 85 83 91
1002020008 Moslu 87 80 81

Student id      : 1002020001
Student name    : Muhit
Total marks     : 255


Student id      : 1002020002
Student name    : Raju
Total marks     : 259


Student id      : 1002020008
Student name    : Moslu
Total marks     : 248

♣ Downloads ::

Comments

Popular posts from this blog

C++ :: Topological Sort Algorithm (using DFS)

How to Hack Facebook Account

C++ :: Strongly Connected Components Algorithm (SCC)