write a program structure to find average of given number

Answer Posted / manjunath

#include<stdio.h>
#include<math.h>
void main()
{
int num,a[100],sum=0;
float average;
printf("enter the number of elements");
scanf("%d",&num);
printf("enter the elements");
for(i=0;i<num;i++)
{
scanf("%d",&a[i]);
}
printf("the elements are");
for(i=0;i<num;i++)
{
printf("%d",a[i]);
}
for(i=0;i<num;i++)
{
sum=sum+a[i];
}
average=sum/num;
printf("%f",average);
}

Is This Answer Correct ?    13 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is a semicolon (;) put at the end of every program statement?

620


Explain Function Pointer?

681


How variables are declared in c?

569


What math functions are available for integers? For floating point?

616


Why is event driven programming or procedural programming, better within specific scenario?

1949






What is the difference between malloc calloc and realloc in c?

643


Explain what is meant by 'bit masking'?

639


How does selection sort work in c?

617


Explain the difference between #include "..." And #include <...> In c?

623


Does sprintf put null character?

595


What is the use of bitwise operator?

683


Can we add pointers together?

612


why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above

605


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

656


what do you mean by enumeration constant?

594