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

Differentiate between the expression “++a” and “a++”?

691


Why isnt there a numbered, multi-level break statement to break out

581


how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software

2783


Is boolean a datatype in c?

535


What are the similarities between c and c++?

591






What are the uses of a pointer?

672


How do you determine whether to use a stream function or a low-level function?

636


What are the loops in c?

589


What are the 5 types of inheritance in c ++?

571


How do you define CONSTANT in C?

644


Explain the difference between strcpy() and memcpy() function?

584


What does *p++ do? What does it point to?

608


Why is not a pointer null after calling free?

587


C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions

603


How can I determine whether a machines byte order is big-endian or little-endian?

611