How to write a program so that you get from the user the number of organs he wants to insert followed by the organs with spaces | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to write a program so that you get from the user the number of organs he wants to insert followed by the organs with spaces

For example the input is :4 100 95 89 70 4: number of grades that the user wants to insert 100 the grade in the first exam (...)

20th Dec 2018, 11:39 AM
Alaa Seh
1 Answer
+ 2
This reads your numbers. It uses the first integer to read that many scores. It doesn't keep those scores at the moment only the last one. You would need an array to store them, if need them all at once. You could add them up and output an average easy without storing them. int n, g; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &g);
20th Dec 2018, 6:38 PM
John Wells
John Wells - avatar