Simple c program for sum and average of n numbers. In this program we can execute the sum and average of n numbers in c programming language.
Float Definition in C
The term “floating point” is abbreviated as “float.” It’s a built-in data type that’s used to create numeric values with floating decimal points, according to the description. Float data type is important method to executed the c program for sum and average of n numbers
For Loop Definition in C
In the C programming language, the for loop is used to iterate statements or parts of a programme numerous times. It is commonly used to traverse data structures such as an array and a linked list.
A for-loop (or simply for loop) is a control flow statement in computer science that specifies iteration and allows code to be executed repeatedly. When the number of iterations is known before entering the loop, for-loops are commonly utilised.
C Program for Sum and Average of n Numbers
//c program for sum and average of n numbers
#include<stdio.h>
int main()
{
int i,n,Sum=0,numbers;
float Average;
printf("\nEnter the Number\n");
scanf("%d",&n);
printf("\nEnter the Number Step by Step\n");
for(i=0;i<n;++i)
{
scanf("%d",&numbers);
Sum = Sum +numbers;
}
Average = Sum/n;
printf("\nSum of the %d Numbers = %d",n, Sum);
printf("\nAverage of the %d Numbers = %.2f",n, Average);
return 0;
}
Enter the Number Step by Step
34
45
23
12
Sum of the 4 Numbers = 114
Average of the 4 Numbers = 28.00
Merge Sort in C Program With Output
C Program to Concatenate String Without Using Strcat
C Program to Check Armstrong Number Using For Loop
Sum of Fibonacci Series in Python Using While Loop
C Program For Palindrome String Using Recursion
Selection Sort Program in Java Example
Merge Sort Program in Java With Output
Quick Sort Program in Java Taking First Element as Pivot
Insertion Sort in Java Using While Loop