Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- struct StudentInfo
- {
- char id[20];
- float cgpa;
- };
- struct StudentInfo students[5];
- float Student_CGPA(char id[])
- {
- int i;
- for(i = 0; i < 5; i++)
- {
- if(strcmp(students[i].id,id)==0)
- {
- return students[i].cgpa;
- }
- }
- }
- int main()
- {
- int i,c=0;
- char id[20];
- for(i=0; i<5; i++)
- {
- printf("\nEnter id: ");
- gets(students[i].id);
- fflush(stdin);
- printf("\nEnter Cgpa: ");
- scanf("%f",&students[i].cgpa);
- fflush(stdin);
- }
- // for(i=0; i<5; i++)
- // {
- // printf("%s\n%0.2f\n", students[i].id,students[i].cgpa);
- // }
- for(i=0; i<5; i++)
- {
- printf("Result of %d no student: %0.2f\n",++c, Student_CGPA(students[i].id));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement