Question : In Bouboun University's Information Systems 3 arrays are used to store student details,
1. Stud_Names (array of strings) holds the name of 100 Students
2. Stud_Map (array of strings) hold the ids of the 100 students (whose details are stored in Stud_Name)
3. Stud_Marks_Mod1 (array of floats) holds the grades of grades of each of the 100 students in Module1
4. Stud_Marks_Mod2 (array of floats) holds the grades of grades of each of the 100 students in Module2
5. Stud_Marks_Mod3 (array of floats)holds the grades of grades of each of the 100 students in Module3
Write a program in C which computes the average marks for each student and displays the highest average.
Problem: when i enter details for the first student it is correct but when i enter the second student details i cannot enter the name it skip it and student ID come in its place ant help how to correct the codes? OPPS I POSTED MY PROBLEM IN THE C++ SECTION SORRY IT WAS IN A HURRY.
My program:
#include <stdio.h>
#include <string.h>
int main()
{
char *Stud_Names[100];
char name;
char Stud_ID[100];
float Stud_Marks_Mod1[100];
float Stud_Marks_Mod2[100];
float Stud_Marks_Mod3[100];
int b=1,i,sum=0;
float avg,avg1;
int max=0;
for(i=0;i<2;i++)
{
printf("Enter student %d name: ", b);
gets(Stud_Names);
Stud_Names[i]=name;
printf("Enter student %d ID: ", b);
scanf("%s", &Stud_ID[i]);
printf("Enter student %d marks for module 1: ", b);
scanf("%f", &Stud_Marks_Mod1[i]);
printf("Enter student %d marks for module 2: ", b);
scanf("%f", &Stud_Marks_Mod2[i]);
printf("Enter student %d marks for module 3: ", b);
scanf("%f", &Stud_Marks_Mod3[i]);
sum = Stud_Marks_Mod1[i] + Stud_Marks_Mod2[i] + Stud_Marks_Mod3[i];
avg1=sum/3;
printf("Average of student %d mark is %.2f \n",i+1,avg1);
b++;
}
if(avg1>max)
{
printf("Highest average mark is %.2f ", avg1);
}