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

Kindle Paperwhite High Resolution Display Tablet | Rs. 9999

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


Responses




Popular Posts

Facebook

Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer and technology lovers. http://www.techstudy.org/.