The problem is :
Write a program that creates an array of N names each name has 5 exam scores. Output the names with the highest and lowest scores.
Now my problem is :
Unsa kulang nako sa kani nga code? so far mu input xag mga names din 5 ka scores din mu compute xag average din mu print out ra xag highest ug lowest na average pero dli ra mu printf ug name nga naay highest ug lowest na score.
Here is my code :
Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char name [][30]={};
int score [5];
int x,y,num;
float sum=0,ave=0;
float large=0,min=1000;
printf("Enter how many elements do you want : \n");
scanf("%d",&num);
fflush(stdin);
for(x=0;x<num;x++)
{
fflush(stdin);
printf("Enter name %d : \n", x);
gets(name[x]);
sum=0;
for(y=0;y<5;y++)//inner loop
{
printf("Enter score %d : \n", y);
scanf("%d", &score[y]);
if(score[y] >0)
sum+=score[y];
else
{
y=0;
sum=0;
}
}
fflush(stdin);
ave=(sum/5);
printf("Average for %s is : %.2f \n", name[x], ave );
if(ave > large)
large=ave;
if(ave < min)
min=ave;
}//outer loop
printf("Highest is %s : %.2f \n", name[x], large);
printf("Lowest is %s : %.2f \n", name[x], min);
getch();
}
Unsa diay kulang ana na code? ngano dli man xa mu print ug name nga ako man xa gibutangan ug %s din name[x] ?... Hope you all can help me. Thanks!