PROGRAM:
#include<stdio.h>
struct student
{
int
rno,m1,m2,m3; float avg;
char name[20],dept[10];
};
void find_student(int
a,struct student s[],int n)
{
int i;
printf("The
Student Detail of %d\n",a); for(i=0;i<n;i++)
{
if(s[i].rno==a)
{
printf("%s\t%s\t%d\t%d\t%d\t%f\n",s[i].name,s[i].dept,s[i].m1,s[i].m
2,s[i].m3,s[i].avg); break;
}
} } main()
{
int
i,n,rno; struct student s[10];
printf("Enter
total no. of Students\n"); scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter
the Student %d Details:\n",(i+1)); printf("Enter the roll
no:\n"); scanf("%d",&s[i].rno);
printf("Enter
the Name:\n"); scanf("%s",&s[i].name); printf("Enter
the Dept:\n"); scanf("%s",&s[i].dept); printf("Enter
the 3 marks:\n");
scanf("%d%d%d",&s[i].m1,&s[i].m2,&s[i].m3);
s[i].avg=(s[i].m1+s[i].m2+s[i].m3)/3;
}
printf("Enter
the rollno to find:\n"); scanf("%d",&rno);
find_student(rno,s,n);
}
OUTPUT:
Enter
total no. of Students 2
Enter
the Student 1 Details: Enter the roll no:
12
Enter
the Name: Kumar
Enter
the Dept: cse
Enter the 3
marks: 45 67 88
Enter
the Student 2 Details: Enter the roll no:
13
Enter the Name:
Prabhu
Enter
the Dept: cse
Enter the 3
marks: 77 89 67
Enter
the rollno to find: 13
The Student Detail of 13
Prabhu
cse 77 89 67 77.000000
No comments:
Post a Comment