In this tutorial, we will discuss a concept of C++ program to add two numbers using pointer
In the C++ programming language, we can use the pointer variable to add two numbers
In this article, we are going to learn how to Display the sum of two numbers using pointer in Cpp language
Program 1
#include <iostream> #include <conio.h> using namespace std; int main() { int num1,num2; //1 int *ptr1,*ptr2; //2 int sum; //3 cout << "Please enter value to num1: "<< endl; //4 cin>>num1; //5 cout << "Please enter value to num2: "<< endl; //6 cin>>num2; //7 ptr1=&num1; //8 ptr2=&num2; sum=*ptr1+*ptr2; //10 cout<<"Sum of the two integer values is: "<<sum; //11 getch(); return 0; return 0; }
When the above code is executed, it produces the following results
Please enter the value to num1: 36 Please enter the value to num2: 44 Sum of two integer values is: 80
Methods
Methods
Similar post
C++ program to add two numbers
C program to add two numbers using pointer
Suggested for you
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…