#include<stdio.h>
struct student
{
int rollno;
char name[100];
float marks[5];
float average;
}s[20];
void get(struct student *a)
{
int i;
float j=0.0;
printf("Enter Roll No. of Student : ");
scanf("%d",&a->rollno);
printf("Enter Name of Student : ");
fflush(stdin);
scanf("%s",&a->name);
for(i=0;i<5;i++)
{
printf("Enter Marks of %d Subject : ",i+1);
scanf("%f",&a->marks[i]);
}
for(i=0;i<5;i++)
{
j+=a->marks[i];
}
a->average=j/5;
}
void print(struct student *a)
{
int i;
printf("\nRoll No : %d",a->rollno);
printf("\nName : %s",a->name);
for(i=0;i<5;i++)
{
printf("\nMarks of Subject %d : %.2f ",i+1,a->marks[i]);
}
printf("\nAverage : %.2f ",a->average);
}
int main()
{
int i;
for(i=0;i<2;i++)
{
get(&s[i]);
}
for(i=0;i<2;i++)
{
if(s[i].average>70)
print(&s[i]);
}
}
struct student
{
int rollno;
char name[100];
float marks[5];
float average;
}s[20];
void get(struct student *a)
{
int i;
float j=0.0;
printf("Enter Roll No. of Student : ");
scanf("%d",&a->rollno);
printf("Enter Name of Student : ");
fflush(stdin);
scanf("%s",&a->name);
for(i=0;i<5;i++)
{
printf("Enter Marks of %d Subject : ",i+1);
scanf("%f",&a->marks[i]);
}
for(i=0;i<5;i++)
{
j+=a->marks[i];
}
a->average=j/5;
}
void print(struct student *a)
{
int i;
printf("\nRoll No : %d",a->rollno);
printf("\nName : %s",a->name);
for(i=0;i<5;i++)
{
printf("\nMarks of Subject %d : %.2f ",i+1,a->marks[i]);
}
printf("\nAverage : %.2f ",a->average);
}
int main()
{
int i;
for(i=0;i<2;i++)
{
get(&s[i]);
}
for(i=0;i<2;i++)
{
if(s[i].average>70)
print(&s[i]);
}
}
No comments:
Post a Comment