Completely Solved C, C++ Programs Assignment.




C Program a structure which reads ‘n’ students information (name,3 subjects marks) and calculate total marks, result print them in a particular format.

Filed Under:

Problem 61. C Program a structure which reads ‘n’ students information (name,3 subjects marks) and calculate total marks, result print them in a particular format.
#include<stdio.h>
#include<conio.h>
main( )
{
struct student
{
char name[20];
int m1,m2,m3, tot;
char result[10];
}stud[10];
int i,n;
clrscr( );
printf(“enter no of students n”);
scanf(“%d”,&n);
for(i=0;i<n;i++)
{
printf(”enter %d student deatails n”,i);
printf(”enter namen”);
scanf(“%s”, stud[i].name);
printf(“enter marks of 3 subjects n”);
scanf(“%d%d%d”, &stud[i].m1,&stud[i].m2,&stud[i].m3);
stud[i].tot=stud[i].m1+stud[i].m2+stud[i].
m3;
if((stud[i].m1>35)&&(stud[i].m2>35)&&( stud[i].m3>35))
strcpy(stud[i].result,”pass”);
else
strtcpy(stud[i].result,”fail”);
}
clrscr( );
printf(“name total result n”);
for(i=0;i<n;i++)
{
printf(“%s %d %s n”,
stud[i].name,stud[i].tot,stud[i].result);
}
getch( );
}

C compiler: gcc 4.1.2

 Back to main directory: Sample C Program | Software Practical | Solved C Assignment


Get Free Programming Tutorials and Solved assignments