Write a C Program to read 10 numbers from user and store them in array Display Sum, Minimum and Average of the numbers

Question: Write a C Program to read 10 numbers from user and store them in array Display Sum, Minimum and Average of the numbers.
Write a C Program to read 10 numbers from user and store them in array Display Sum, Minimum and Average of the numbers

What is Array explain?
   Array. An array is a data structure that contains a group of elements. Typically these elements are all of the same data type, such as an integer or string. Arrays are commonly used in computer programs to organize data so that a related set of values can be easily sorted or searched.

How do you find the average of numbers in an array?
   Average is the sum of array elements divided by the number of elements. Examples : Input : arr[] = {1, 2, 3, 4, 5} Output : 3 Sum of the elements is 1+2+3+4+5 = 15 and total number of elements is 5

Program To Calculate Average In C
  • Algorithm. Algorithm of this program is very easy − START Step 1 → Collect integer values in an array A of size N Step 2 → Add all values of A Step 3 → Divide the output of Step 2 with N Step 4 → Display the output of Step 3 as average STOP.
  • Pseudocode.
  • Implementation.
  • Output.
  1. /*
  2. Write a C Program to read 10 numbers from user and store them in array Display Sum, Minimum and Average of the numbers
  3. */

  4. #include <stdio.h>

  5. int main() 
  6. {
  7.  int a[10],i,min,sum=0;
  8.  for(i=0;i<10;i++)
  9.  {
  10.     printf("\n Enter Interger Value [%d] : ",i+1);
  11.     scanf("%d",&a[i]);
  12.     sum=sum+a[i];
  13.     if(i==0)
  14.     {
  15.       min=a[i];
  16.     }
  17.     else
  18.     {
  19.       if(min>a[i])
  20.       {
  21.        min=a[i];
  22.      }
  23.   }
  24.  }
  25.  printf("\n Sum     : %d",sum);
  26.  printf("\n Minimum : %d",min);
  27.  printf("\n Average : %f",((float)sum/i));
  28.  return 0;

  29. }
Output:
Output of Write a C Program to read 10 numbers from user and store them in array Display Sum, Minimum and Average of the numbers

Download the Android app to get all Government Job Notifications on your Mobile.
Download Now
Important: Please always Check and Confirm the above details with the official Advertisement / Notification.
Previous Post Next Post