hey i am new to the forum and i have being studying c for about a month now, and i need help with a part of a programe? here is the question:
An assessor is interested to compare the results of the same group of students at three
different modules. Write a program that reads the average grade for each of the three
modules and displays statistics in the order of their results in the following format.
NAME average
EM103 60
EM106 50
EM108 45
im not asking you to do the question, i want to know how to get the grades in order and have the subject stay along side them, here is what i have written so far
Code:
#include<stdio.h>
#include<string.h>
int main ()
{
int i,j,t;
float avg1, avg2, avg3;
char mod1[] = {"em108"}, mod2[] = {"em109"}, mod3[]= {"em102"};
printf("%s\t", mod1);
scanf("%f", &avg1);
printf("%s\t", mod2);
scanf("%f", &avg2);
printf("%s\t", mod3);
scanf("%f", &avg3);
printf("\nmodule\t grade\n");
printf("%s %.2f\n", mod1, avg1);
printf("%s %.2f\n", mod2, avg2);
printf("%s %.2f\n", mod3, avg3);
return 0;
}
i have been able to get the grades and module to be beside each other but as i said i don't know how to get them in order.
my teacher told me to use the strcpy function but i haven't been able to find any good examples on the internet or in any books, and any help at all would be a great help. thank you.