[Let us C Solution ]C Program to find the average of n (n < 10) numbers using arrays





  1. // Program to find the average of n (n < 10) numbers using arrays
  2. #include <stdio.h>
  3. int main()
  4. {
  5. int marks[10], i, n, sum = 0, average;
  6. printf("Enter n: ");
  7. scanf("%d", &n);
  8. for(i=0; i<n; ++i)
  9. {
  10. printf("Enter number%d: ",i+1);
  11. scanf("%d", &marks[i]);
  12. sum += marks[i];
  13. }
  14. average = sum/n;
  15. printf("Average = %d", average);
  16. return 0;
  17. }

Output
Enter n: 5
Enter number1: 45
Enter number2: 35
Enter number3: 38
Enter number4: 31
Enter number5: 49
Average = 39


Comments

Popular posts from this blog

HTML Signup Login Form With Source Code