Program to illustrate Call by Value

  
          #include <iostream.h>
          #include <conio.h>
        void swap1 (int i, int  j);                             // Function prototype 
           void main( )
          {
        int a = 5, b =25 ;
        swap1 (a, b);                                          // Call by Value
        cout<<"\n a = "<<a<<"\t b = "<<b;
        getch( );
           }

           void  swap1 (int x, int y)                          // Function definition
        {
            int temp;
                          // To interchange 2 numbers
            temp = x;
            x = y;
            y = temp ;
            cout<<"\n x = "<<x<<"\t y= "<<y;
            }

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|