write a program in C using struture to calculate marks of 10 students in different subjects
#include<stdio.h>
#include<conio.h>
struct student // sturcture for student
{
int sub1; //subject 1
int sub2; //subject 2
int sub3; //subject 3
};
void main()
{
struct student s[10];
int i,total=0;
clrscr();
for(i=0;i<=2;i++) // loop
{
printf("\nEnter Marks in Three Subjects = ");
scanf("%d%d%d",& s[i].sub1,&s[i].sub2,&s[i].sub3);
total=s[i].sub1+s[i].sub2+s[i].sub3; // total to calculate
printf("\nTotal marks of s[%d] Student= %d",i,total);
}
getch();
}
No comments:
Post a Comment