C Program to Add Two Numbers Using Pointers

In this program, you'll learn to add two numbers using pointers.



Source Code
#include<stdio.h>
int main()
{
    int a, b, sum;
    int *p, *q;

    printf("Enter two numbers: ");
    scanf("%d%d", &a, &b);

    p = &a;
    q= &b;
    sum = *p + *q;

    printf("\nSum of given two nos = %d", sum);
    return 0;
}
Output
Enter two numbers:
48
98

Sum of given two nos = 146





"Coding Hub - Learn to code" app now available on Google Play Store