Question: 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?
How do you find the average of numbers in an array?
Program To Calculate Average In C
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.
- /*
- Write a C Program to read 10 numbers from user and store them in array Display Sum, Minimum and Average of the numbers
- */
- #include <stdio.h>
- int main()
- {
- int a[10],i,min,sum=0;
- for(i=0;i<10;i++)
- {
- printf("\n Enter Interger Value [%d] : ",i+1);
- scanf("%d",&a[i]);
- sum=sum+a[i];
- if(i==0)
- {
- min=a[i];
- }
- else
- {
- if(min>a[i])
- {
- min=a[i];
- }
- }
- }
- printf("\n Sum : %d",sum);
- printf("\n Minimum : %d",min);
- printf("\n Average : %f",((float)sum/i));
- return 0;
- }
Output: