Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. struct StudentInfo
  4. {
  5. char id[20];
  6. float cgpa;
  7. };
  8.  
  9. struct StudentInfo students[5];
  10.  
  11. float Student_CGPA(char id[])
  12. {
  13. int i;
  14. for(i = 0; i < 5; i++)
  15. {
  16. if(strcmp(students[i].id,id)==0)
  17. {
  18. return students[i].cgpa;
  19. }
  20. }
  21. }
  22. int main()
  23. {
  24. int i,c=0;
  25. char id[20];
  26. for(i=0; i<5; i++)
  27. {
  28. printf("\nEnter id: ");
  29. gets(students[i].id);
  30. fflush(stdin);
  31.  
  32. printf("\nEnter Cgpa: ");
  33. scanf("%f",&students[i].cgpa);
  34. fflush(stdin);
  35. }
  36. // for(i=0; i<5; i++)
  37. // {
  38. // printf("%s\n%0.2f\n", students[i].id,students[i].cgpa);
  39. // }
  40. for(i=0; i<5; i++)
  41. {
  42. printf("Result of %d no student: %0.2f\n",++c, Student_CGPA(students[i].id));
  43. }
  44.  
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement