Know the amount of data entered in C | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Know the amount of data entered in C

Hi. I would like to know how to make a program such that the user enters a list of numbers (without saying how many), and the program says how many numbers were entered. Using this, how can we calculate the average of all the numbers? For example, I am looking for a program such that, if the user enters 2, 4, 6; the program says : You entered 3 numbers, and its average is 4.

23rd Oct 2019, 2:04 AM
Iván García Mestiza
Iván García Mestiza - avatar
1 Answer
0
You can use the concept of linked list. Initialize array at runtime and add condition which ask user if he want to enter more values into it's list then you get how many values he entered and then you can find average as well!
23rd Oct 2019, 8:39 AM
Chirag Kumar
Chirag Kumar - avatar