SCHOOL OF CODE BUILDERS
Learn To CODE. Become A DEVELOPER.
Pages
HOME
DATA STRUCTURES
STRINGS
ARRAYS
MATRIX
BINARY TREES
LINKED LIST
STACK
QUEUE
SORTING
SEARCHING
C
PYTHON
PSEUDOCODE
CONTEST PROBLEMS
ALGORITHMS
PATTERNS
PHP
C PUZZLES
C INTERVIEW QUESTIONS
JAVA
C++
HASHING
RECURSION
BASIC C PROGRAMS
TCS-CODEVITA
FACEBOOK
CONTACT US
C program to calculate average
C program to calculate average
Output:
Enter the number of items: 5
Enter the items one by one to find its average:
1.5 2.5 3.5 4.5 5.5
The average of entered items is 3.500000
Implementation:
#include
int main(void) { int i,n; float average,x,sum=0; printf("Enter the number of items:\n"); scanf("%d",&n); printf("Enter the items one by one to find its average:\n"); for(i=1;i<=n;i++) { scanf("%f",&x); sum = sum + x; } average = (float)(sum/n); printf("The average of entered terms is %f",average); return 0; }
PREVIOUS
NEXT
HOME