Program to print the average of n numbersThe average is the outcome from the sum of the numbers divided by the count of the numbers being averaged. For example: 1,2,3,4,5 Number of all elements = 5 Sum of all elements = 1+2+3+4+5 =15 Average = Sum of all elements / number of all elements = 15/5 =3 Average =3 Algorithm
Java ProgramOutput: Enter the value of n 5 Enter the 1 number? 1 Enter the 2 number? 2 Enter the 3 number? 3 Enter the 4 number? 4 Enter the 5 number? 5 The Average is 3.0 C programOutput: Enter the value of n? 5 Enter the 1 number? 1 Enter the 2 number? 2 Enter the 3 number? 3 Enter the 4 number? 4 Enter the 5 number? 5 The Average is 3.0000 Python programOutput: Enter the value of n? 5 Enter the 1 number? 1 Enter the 2 number? 2 Enter the 3 number? 3 Enter the 4 number? 4 Enter the 5 number? 5 Average using a while loop 3.0000 Php programOutput: Enter the value of n? 5 Enter the number 1 Enter the number 2 Enter the number 3 Enter the number 4 Enter the number 5 3.0000 C# programOutput: Enter the value of n? 5 Enter the 1 number? 1 Enter the 2 number? 2 Enter the 3 number? 3 Enter the 4 number? 4 Enter the 5 number? 5 The Average is 3.0 Next Topic# |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India