Monday 12 November 2012

C Program to Prepare Total Marks For N Number of Students

By

Program to prepare the total marks for N students by reading the Regno,, Name, Mark1 to Mark6 by using array of structures.

Program :-


#include<stdio.h>
#include<conio.h>
struct stu
{
int no;
char stuname[100];
int mark[20];
int totalmarks;
};
void main()
{
clrscr();
struct stu s[50];
int n,i,j;
printf("Enter Number of Students : ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\n Enter Number,Student name and 6 Marks one by one\n");
scanf("%d%s",&s[i].no,s[i].stuname);
for(j=0;j<=5;j++)
{
scanf("%d",&s[i].mark[j]);
}
}
printf("\n*******************************************");

printf("\nwww.flintgroups.com");
printf("\nNumber\tNmae\tTotalMarks");
printf("\n*******************************************\n");
for(i=0;i<n;i++)
{
s[i].totalmarks=0;
for(j=0;j<6;j++)
{
s[i].totalmarks=s[i].totalmarks+s[i].mark[j];
}
printf("%d\t%s\t%d\n",s[i].no,s[i].stuname,s[i].totalmarks);
}
getch();
}



The Sample output for this program is as shown below.

Output : -

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Labels