Advertisement
vaibhav1906

Pass by Reference

Nov 16th, 2021
903
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.23 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. void addOne(int &a){
  5.     a = a+1;
  6.    
  7.     cout<<"Value of a in function = "<<a<<endl;
  8.    
  9. }
  10.  
  11. int main(){
  12.    
  13.     int a = 5;
  14.     addOne(a);
  15.    
  16.     cout<<"Value of a = "<<a<<endl; // Output : 6
  17.    
  18.    
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement