© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu
Quick Links
Easy Studies

Home Lab Exercise Object Oriented Programming Lab Exercise ProgramsCPP Program For Call By Value▼


CPP Program For Call By Value

Alogarithm steps:

  1. Start the program
  2. Write the function and pass one value through that function
  3. Call that function in the main program
  4. Pass the value when we call that function
  5. Compile and run the program

CPP Program For Call By Value

#include void doubleIt(int); int main () { int num; cout << "Enter number: "; cin >> num; doubleIt(num); cout << "The number doubled in main is " << num << endl; return 0; } void doubleIt (int x) { cout << "The number to be doubled is " << x << endl; x *= 2; cout << "The number doubled in doubleIt is " << x << endl; }

SAMPLE INPUT AND OUTPUT:

 Enter number:

3

The number to be doubled is:3

The number doubled in doubleIt is6

The number doubled in main is:3

 

 
SLogix Student Projects

⇓Student Projects⇓
⇑Student Projects⇑
bottom