Wednesday, March 6, 2013

C Language Example # 32 Find average from array elements


C Language Example # 32 Find average from array elements

* Program will find average value after searching all elements from array.

//Written by Latest Technology Guide    
//Title : C Language Example # 
32 Find average from array elements


#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int a[10]={0},i,sum=0,od=0,ev=0;

printf("\n Now Enter Value for Array A : \n");

for(i=0;i<10;i++)
{
printf("a[%d] = ",i);
scanf("%d",&a[i]);
}

for(i=0;i<10;i++)
sum=sum+a[i];

printf("\n\n\t\t : Average of Array is : %5.2f",sum/10.0);

getch();
}



Output:

* Program will display average value from array elements.

--------------------------------------------------------------------------------
Explanation of C Programming Language Example # 32 Find average from array elements


* Program will create static array.
* Program will scan value from users and will store into array.
* Program will find sum of all elements
* Program will find average from sum.

Note: All programs are developed and tested using Turbo C++ 3.0 under Windows XP. We just want to provide guidelines to the users. If you are using any other Compiler or other operating system they you need to modify this program as per your requirements. 

No comments:

Post a Comment