Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define SIZE 20
- #define MAX 100
- struct studentInfo
- {
- char name[SIZE];
- int n;
- };
- int main()
- {
- struct studentInfo s[MAX];
- int n, i, max, maxPosition;
- printf("How many students? ");
- scanf("%d", &n);
- getchar();
- for(i = 0; i < n; i++)
- {
- printf("Enter the name of stduent %d: ", i+1);
- gets(s[i].name);
- printf("Enter the number of student %d: ", i+1);
- scanf("%d", &s[i].n);
- getchar();
- }
- max = s[0].n;
- maxPosition = 0;
- for(i = 1; i < n; i++)
- {
- if(s[i].n > max)
- {
- max = s[i].n;
- maxPosition = i;
- }
- }
- printf("Maximum number obtained is %d by %s\n", max, s[maxPosition].name);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement