WAP using functions which inputs 6 numbers from user and calculate sum and average of all and print it in main function itself.

(Hint: use pointers)
 #include<stdio.h>
 #include<stdlib.h>

void func(int *,float *,float *);
 main()
 {
 int a[6],i;
 float sum,avg,fun;
sum=0;
 printf("enter 6 numbers");
for(i=0;i<6;i++)
 scanf("%d",&a[i]);
func(a,&sum,&avg);
 printf("%f\n%f",sum,avg);
system("pause");
 }
void func(int *x,float *s,float *av)
 {
int j;
 for(j=0;j<=5;j++)
 *s=*s + *(x+j) ;
*av=*s/6;
 }
Advertisements

Leave a comment

Filed under TUTORIALS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s