Could you please be a little bit more specific as to what is not working?
Also this line:
1 2
//line 37
system("cls");
is clearing the console window text during each iteration of x<3, possibly it works, but you can't see the output as you're clearing the screen after every iteration?
you're right, once compiled and executed, the code is developed right the first time the cycle "for" but not the second time to capture the full name. It is there where I do not know what is wrong.
1 2 3 4
cout<<"\n Full Name: ";
// gets(nom);
fgets(nom,50,stdin);
thanks NwM.-
I clean the screen to the previous iteration not be seen by the user, in the end I get a summary of students and on-screen averages. But I fail.
vlad from moscow (1030)
Sorry but I can compile the code.
@josan
vlad from moscow (1030)
Sorry but I can compile the code.
It is only because you uses the compiler incorrectly. You shall switch off C features because your program is C++.
Moreover your program is invalid in whole.
thank you for your support. I still have much to learn, perhaps due to start by explaining to do my program.
A. - Capture the full name of 20 students.
2. - Capture if male or female.
3. - Capture three grades each.
4. - Save in a list the average of each student.
5. - To display: Full name / sex / average.
Then you would need for (x=0;x<20;x++), currently you only have 3 iterations.
What the previous posters meant is that your code is using
- C syntax and libraries, not recommended in c++
- ambiguous variable declarations
If you also need to store the names of each student, you should use a string array: string names[20]; . If you don't need to store them, it's probably still the best to use a string rather than char[50].
As I said, using a string gives you the benefit of being able to use std::cin, in stead of fgets().
I could rewrite your objectives as following instructions:
Do the following for 20 students:
- Ask their name
- Ask if they are male or female
- Ask three grades and save the average for every student in a list
- Display the information in following format: Full name / sex / average.