calculate sum and average with pointers in c

 #include<stdio.h>


void SumAndAvg( int a,  int b, int *sum, float *avg){

*sum = a + b;

*avg = (float)(*sum)/2;

}


int main()

{     

int i, j, sum;

float avg;

printf("Enter the value of i %d");

scanf("%d", &i);

    printf("Enter the value of j %d");

scanf("%d", &j);

    SumAndAvg( i, j, &sum, &avg);

    

printf("The value of sum is %d\n", sum);

printf("The value of avg is %f\n", avg);

return 0;

}

Comments

Popular posts from this blog

create a num table in a new file in c

write a programme to compare time stamp in c

write a struct programme to keep bank details in c