GoogelAddUnit1

Monday, 16 April 2012

WRITE A C-PROGRAM TO DEFINE A STRUCTURE WITH THE STUDENT NUMBER,NAME,M1,M2,M3 FIND THE RESULT OF DIFFERENT STUDENTS.

AIM:A program to find the result of different students using structures.
PROGRAM:
#include<stdio.h>
struct stu
{
int no,m1,m2,m3;
char name[20];
float ave;
}s[50];
main()
{
int i,n;
printf("enter the no.of students");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
printf("enter the values of number,name,m1,m2,m3");
scanf("%d%s%d%d%d",s[i].no,s[i].name,s[i].m1,s[i].m2,s[i].m3);
s[i].avg=(s[i].m1+s[i].m2+s[i].m3)/3;
for(i=0;i<=n;i++)
{
if((s[i].m1>=35)&&(s[i].m2>=35)&&(s[i].m3>=35))
{
if((s[i].avg>=75)&&(s[i].avg<=100))
printf("distinction");
else
if((s[i].avg>=60)&&(s[i].avg<75))
printf("first class");
else
if((s[i].avg>=50)&&(s[i].avg<60))
printf("second class");
else
printf("third class");
}
else
printf("fail");
}
}
OUTPUT:
enter the values of no,name,m1,m2,m3
2,sneha,78,67,45
distinction

No comments:

Post a Comment