C Program to add two numbers using pointers


In this program, You will learn how to add two numbers using pointers in c.


25 = 15 + 10

30 = 10 + 20


Example: How to add two numbers using pointers in c

Run it Now
#include<stdio.h>

int main() {

   int x, y, sum;
   int *a, *b;

   printf("Enter Two Numbers :");
   scanf("%d%d", &x, &y);

   a = &x;
   b = &y;

   sum = (*a) + (*b);
   printf("\nThe Sum is :%d", sum);

   return 0;
}

Output:

Enter Two Numbers :12 13
The Sum is :25