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
Why is a semicolon (;) put at the end of every program statement?
Explain Function Pointer?
How variables are declared in c?
What math functions are available for integers? For floating point?
Why is event driven programming or procedural programming, better within specific scenario?
What is the difference between malloc calloc and realloc in c?
Explain what is meant by 'bit masking'?
How does selection sort work in c?
Explain the difference between #include "..." And #include <...> In c?
Does sprintf put null character?
What is the use of bitwise operator?
Can we add pointers together?
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
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?
what do you mean by enumeration constant?