© 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 Functions With Default Arguments▼


CPP Program for Functions With Default Arguments

Alogarithm steps:

  1. Start the program
  2. Write one function with default arguments
  3. Call that function in the main program
  4. The function be called without arguments, with single arguments, with two arguments
  5. Compile and run the program.

CPP Program for Functions With Default Arguments

#include void f(int a=0, int b=0) { cout << "a: " << a << " b: " << b; cout << '\n'; } int main() { f (); f (10); f(10, 99); return 0; }

SAMPLE INPUT AND OUTPUT:

 Function f()

a:0

b:0

Function f(10)

a:10

b:0

Function f(10,99)

a:10

b:99

 
SLogix Student Projects

⇓Student Projects⇓
⇑Student Projects⇑
bottom