18.Return value without return keyword
#include <stdio.h>
void sumAndavg(int x, int y,int *sum,float *avg)
{
*sum=x+y;
*avg=(float)(x+y)/2;
}
int main()
{
int a, b,sum;
float avg;
printf("Enter two natural numbers :");
scanf("%d %d", &a, &b);
sumAndavg(a,b,&sum,&avg);
printf("\nThe sum is %d and average is %0.2f",sum,avg);//2 zeros after decimal
return 0;
}
Comments
Post a Comment