Sunday, July 31, 2016

Average Program Through Pointer- C Language

Average Program Through Pointer

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;float p;
float avg(int *x,int *y);

clrscr();
printf("Enter Your  Two Values for Avg::");
printf("\nEnter Your 1st No.::");
scanf("%d",&a);
printf("Enter Your 2nd No.::");
scanf("%d",&b);
p=avg(&a,&b);
printf("The Avg values are \n a=%d \n b=%d \n avg=%f",a,b,p);


getch();
}
float avg( int *x,int *y)
{
int temp;
return((*x+*y)/2);
}
/*output


Enter Your  Two Values for Avg::
Enter Your 1st No.::12                                                          
Enter Your 2nd No.::23                                                          
The Avg values are                                                              
a=12                                                                           
b=23                                                                           
avg=17.000000

*/

No comments:

Post a Comment