Ok I made a simple program (2 days of learning C btw)
It accepts the names and grades of the number of students entered and then finds their percentage based on the total marks of the exam. Problem:It only prints the percentage grade of one student. Please help.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
int main()
{
char fName[50][256];
char lName [50] [256];
int grades [50][256];
int num,i,b,c;
int total;
float average;
printf("Enter total marks for the examination:");
scanf("%d",&total);
printf("Enter number of students:");
scanf("%d",&num);
for (i=0;i<num;i++){
printf("Enter their first names: ");
scanf("%s",fName[i]);
printf("Enter their last names: ");
scanf("%s",lName[i]);
}
printf("Enter student's grade beside their name\n");
for (b=0;b<num;b++){
printf("%s ",fName[b]);
printf("%s ",lName[b]);
scanf("%d",grades[b]);
printf("%s Grade:",fName[b]);
average=(grades[b][b]/total)*100;
printf("%.2f \n",average);
}
return 0;
}