Friday, 27 April 2012

Addition using pointer


#include<stdio.h>
#include<conio.h>

void main()
{
   int   first, second, *p, *q, sum;

   printf("Enter two integers to add\n");
   scanf("%d%d", &first, &second);

   p = &first;
   q = &second;

   sum = *p + *q;

   printf("Sum of entered numbers = %d\n",sum);

   return 0;
}

output:-

Enter two numbers:-
10
20
sum of entered number=30

No comments:

Post a Comment