Write C++ program to add two numbers using pointers


I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

Introduction

I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.


  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int num1, num2, *ptr1, *ptr2, sum=0;
  7. cout<<"Enter the two number :";
  8. cin>>num1>>num2;
  9. ptr1 = &num1;
  10. ptr2 = &num2;
  11. sum = *ptr1 + *ptr2;
  12. cout<<"Sum of the two number is "<<sum;
  13.  
  14. return 0;
  15.  
  16. }
  17.  

Result

C++ language techstudy.org

     





Related Topics




Popular Posts