बिजनेस मार्केटिंग का लो कॉस्ट फंडा , अपने मोबाइल से ऑटो sms भेजकर मार्केटिंग करे विजिट करे http://autotextsms.com/ बिजनेस मार्केटिंग का लो कॉस्ट फंडा http://autotextsms.com/

Search This Blog

Translate

Showing posts with label C Program to calculate average using arrays. Show all posts
Showing posts with label C Program to calculate average using arrays. Show all posts

C Program to calculate average using arrays

C Program to calculate average using arrays 

#include <stdio.h>
 int main()
 { int n, i; float num[100], sum=0.0, average; printf("Enter the numbers of data: "); scanf("%d",&n); while (n>100 || n<=0) { printf("Error! number should in range of (1 to 100).\n"); printf("Enter the number again: "); scanf("%d",&n); } for(i=0; i<n; ++i) { printf("%d. Enter number: ",i+1); scanf("%f",&num[i]); sum+=num[i]; } average=sum/n; printf("Average = %.2f",average); return 0; }


OUTPUT:-

 --------------------------------
 Enter the numbers of data: 2 1. Enter number: 7 2. Enter number: 9 Average = 8.00
--------------------------------



C Program example List