Program to add two numbers using pointers in C

#include <stdio.h>

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

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

   p = &first;
   q = &second;

   sum = *p + *q;

   printf("Sum of entered numbers = %dn",sum);

   return 0;
}

Output
Enter two integers to add
5
3
Sum of entered numbers =8

Leave a Reply

Your email address will not be published. Required fields are marked *