Write a program in C++ to add two numbers using pointers

Algorithm to add two numbers using pointer

  1. Firstly, Initialize two variables of integer type.
  2. Secondly, Initialize two pointers of integer type.
  3. Thirdly, Reference the pointers to variables with the help of ‘&’ operator.
  4. With the help of  * operator, access the address pointed by pointers.
  5. Sum the values of variables, and store it on another variable.
  6. Display the sum after calculations.

C++ Program to add two numbers using pointers

Write a program in C++ to add two numbers using pointers.

Output

Enter the first number:

4

Enter the second number:

5

The Sum is: 9

Add a Comment