C++ program to demonstrate call by value


//call by value method in c++
#include<iostream.h>
#include<conio.h>
int cube(int);
void main()
{
          int n;
          cout<<"Enter the number";
          cin>>n;
          n=cube(n);
          cout<<"Cube of the number is:"<<n;
          getch();
}
int cube(int n)
{
          n=n*n*n;
          return n;
}

Output
call by value, pass by value c++ progarm: Sample output
C++ program to demonstrate call by value

No comments: