C++ program to print the addition of two numbers using pointers

C++ program to print the addition of two numbers using pointers. Using this program you can print the addition of two numbers. Addresses are represented by pointers, which are symbolic representations of them.

They allow programs to generate and modify dynamic data structures as well as imitate call-by-reference. Its standard C/C++ declaration looks like this: Syntax: datatype *var name; int *ptr; /ptr can point to an address that contains int data.

#include <iostream>
using namespace std;
int main()
int a, b;
int *ptr1,* ptr2;
int sum;
cout<<"\n Enter first number";
cout<<"\n Enter second number";
ptr1 = &a;
ptr2 = &b;
sum = *ptr1 + * ptr2;
cout<<"\n Sum is: "<< sum;
return 0;


Enter first number 34

Enter second number 45

Sum is: 79

What is pointer in c++ program

A variable that stores the address of another variable is known as a pointer. A pointer is a variable that holds the address of a variable, unlike other variables that hold values of a specific type. An integer variable, for example, stores (or holds) an integer value, whereas an integer pointer holds the address of an integer variable.

What is cin in c++ program

In C++, the cin object belongs to the istream class. It accepts input from a normal input device, such as a keyboard. It’s linked to stdin, the standard C input stream. For reading inputs, the extraction operator(>>) is combined with the object cin.