Signup/Sign In

C Program to Add two user input numbers using Pointers

Few important points to remember:

  • * operator returns 'value at' on the given address location.
  • & operator returns 'address of' a given value.

Below is a program adding two numbers using pointers.

#include<stdio.h>

int main()
{
    printf("\n\n\t\tStudytonight - Best place to learn\n\n\n");
    int first, second, *p , *q, sum;
    printf("Enter two integers to add using pointers:\n");
    scanf("%d%d", &first, &second);
    p = &first;
    q = &second;
    sum = *p + *q;
    printf("\n\nThe sum of the entered numbers is: %d", sum);
    printf("\n\n\t\t\tCoding is Fun !\n\n\n");
    return 0;
}

Output:

C program output for Adding two numbers using pointers