1. ## Average

I am new to C prog. and I was wondering how to find average of numbers that a user enters.
Thanks for help.

2. Take the sum and divide by the number of numbers. What have you tried?

3. ## avegare

i just did that, but i was wondering if there is an average command, or if that is the only way to do average.

4. To the best of my knowledge, there is no function in the C standard library for computing an arithmetic mean. There are probably other ways to calculate the mean when say, a sum is too large to be stored in the variable, but I am not certain about such methods. And, of course, the mean is just one way to take the average, the median and mode being two other ways.

5. so there is no way to calculate average??? with a command.....

6. "Function", not "command". You can write your own function, if necessary.

7. if you are very new to C and procedural programming, your best bet is to read the tutorials on the main cprogramming.com site.

once getting a basic introduction to a c programs structure, console input and output, functions, primitive data types (for example int and char) then you might be able to translate the following pseudo code into a c program. for simplicity, the function will take in 3 numbers (integers) and print the average
Code:
```function printAverage(int number1, int number2, int number3)
define sum as integer
set sum = 0
define average as floating point value (ie real number)
set average = 0

set sum = sum + number1
set sum = sum + number2
set sum = sum + number3

set average = sum / 3

print average```

Popular pages Recent additions