Hi I think this is my first post, so here it goes:
Overview:
This program declares global bidimensional array of 30 rows and 5 columns (not counting 0 in the rows) of floating type to save information of students, table is as follows:
ID Partial1 Partial2 Partial3 Partial4 Average
ID: em..I
Partial N: Students grade of a evaluation.
Average: well students final grade.
the grade can't be higher than 10.
Problem:
Ok so my problem is that when I start inputing data everything goes well until we input more than 1 student, when I enter the second ID it is saved but the second student's ID overwrites the last student's average, having the ID duplicated and the las average erased, and i can't figure out why is this happening, I've looked at the code for hours, so any help is really appreciated, by the way I'm relatively new to c++.
Notes:
//Start of data input
for (row= 1;row<=30;row++){
Sum=0;//reset acumulator.
printf("\nStudent %d.", row);
printf("\n\tAverage: ");scanf("%f",&alumno[row][0]);
for (col=1;col<=4;col++){
printf("\n\tPartial %d: ",col);scanf("%f",&alumno[row][col]);
Sum=Sum+alumno[row][col];//acumulating values for average
}
alumno[row][5]=Sum/4; //this is the average
printf("\nAverage: %0.2f", alumno[row][5]);
}//end of input
Output
ID P1 P2 P3 P4 Av
10 10 10 10 10 9
9 9 9 9 9 6
6 6 6 6 6 6
Data of 3 students
assuming you use 10 for all of the first student's data, 9 for the second and 6 for the third.
see how the last value of the first and second student gets replaced by the ID of the next one.