could do with a bit of help out there off anyone who knows much bout c im a complete novice here
so far we have only been doing code using #include<stdio.h>
much appreciated from who ever helps me out here
The main function is to consist of function calls only.
At least three functions are to be used to allow the user to:
1. Input the names and surnames of up to 30 students, using a for loop.
2. Input the names of up to six subjects, using a while loop.
3. Input the marks achieved by each student in the subjects, using a do while loop.
4. Calculate the average mark for each student.
5. Output the name and average mark for each student.
The user is to be allowed repeat the entire process as often as she wishes.
i have a sample one here that needs to be modified help would be much appreciated
Code:
#include<stdio.h>
char Names[30][10];
int SUB1[30];
int SUB2[30];
int SUB3[30];
float AVG[30];
int num,i,val;
main()
{
clrscr();
select();
}
select()
{
printf("\n do you want to input or to exit?");
printf("\n input 1 to go to input function 2 to exit");
scanf("%d",&val);
if(val==1)
input();
else
exit(1);
}
input()
{
i=0;
printf("\n how many names do you want to input?");
scanf("%d",&num);
for(i=0;i<num;i++)
{
printf("\n what is the name %d: ?",i+1);
scanf("%s",&Names[i]);
printf("\n what is mark %d:?",i+1);
scanf("%d",&SUB1[i]);
printf("\n what is mark %d:? for sub 2",i+1);
scanf("%d",& SUB2[i]);
printf("\n what is mark %d:? for sub3 ",i+1);
scanf("%d",&SUB3[i]);
}
calc();
getch();
}
calc()
{
i=0;
while(i<num)
{
AVG[i]=(SUB1[i]+SUB2[i]+SUB3[i])/3;
i++;
}
output();
}
output()
{
i=0;
do
{
printf("\n your name is : %s",Names[i]);
printf("\n your marks are : %d %d %d",SUB1[i],SUB2[i],SUB3[i]);
printf("\n your average is: %5.2f",AVG[i]);
i++;
}
while(i<num);
getch();
Repeat();
}
Repeat()
{
int val1;
printf("\n do you want to repeat or to exit?");
printf("\n input 1 to go to select() function ,2 to exit");
scanf("%d",&val1);
if(val1==1)
select();
else
exit(1);
}