Array is a must known concept through array we can perform many task or program.
So , an another program that will help you to understand array more easily.
/* Pre-Processors*/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define MAX 25 /* Length of MAX*/
void main()
{
float array[MAX];
float i, num, sum=0;
float avg=0;
clrscr();
printf("\nEnter no. of Element for your array:- ");
scanf("%f",&num);
for(i=0;i<num;i++)
{
printf("\nEnter value:- ");
scanf("%f",&array[i]);
}
for(i=0;i<num;i++)
{
sum=sum+array[i];
}
avg=sum/num;
printf("\nAverage of the given values is %f",avg);
getch();
}
So , an another program that will help you to understand array more easily.
/* Pre-Processors*/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define MAX 25 /* Length of MAX*/
void main()
{
float array[MAX];
float i, num, sum=0;
float avg=0;
clrscr();
printf("\nEnter no. of Element for your array:- ");
scanf("%f",&num);
for(i=0;i<num;i++)
{
printf("\nEnter value:- ");
scanf("%f",&array[i]);
}
for(i=0;i<num;i++)
{
sum=sum+array[i];
}
avg=sum/num;
printf("\nAverage of the given values is %f",avg);
getch();
}
No comments:
Post a Comment