Thursday, August 27, 2009

Add Two Number Using Pointer

#include
#include
void main()
{
int a,b;
clrscr();
printf("\n\t Enter First Value : ");
scanf("%d",&a);
printf("\t Enter Second Value : ");
scanf("%d",&b);
printf("\n\t The Sum of %d + %d = %d",a,b,add(&a,&b));
getch();
}
int add(c,d)
int *c,*d;
{
int sum=0;
sum=*c+*d;
return(sum);
}

Output
Enter First Value : 2
Enter Second Value : 3
The Sum of 2 + 3 = 5

No comments:

Post a Comment