Object Oriented Concepts and Programming

Blog is for Object oriented concepts and prgramming. Specially for MCA GTU (Gujarat Technological University) student

RSS
  • Home
  • Edit

Showing posts with label Defualt Argument. Show all posts
Showing posts with label Defualt Argument. Show all posts

How To Implement Default Argument in Function.

Thursday, April 8, 2010 by Vishal Joshipura | 1 comments
/*
This code shows how to use default argument in function
or how to create an optional parameter to the function

*/

#include

void div(int a,int b=1)
{
    float c;
    cout<<<"A is "<
    cout<<<"B is "<
    c= float(a)/b;
    cout<<<"A / B is "<
}


int main(void)
{
    int i=10,j=2;
    cout<<<"Default Argument";
    div(i,j);
    div(i);
    return 0;
}

/* Here Second parameter of div() function is
optional we can ommit it autometically consider
as Default argument value as 1*/

Defualt Argument

Subscribe to: Posts (Atom)

Blog Archive

  • ▼  2010 (10)
    • ▼  November (1)
      • Google Android
    • ►  August (3)
    • ►  May (2)
    • ►  April (3)
    • ►  March (1)

Followers

Labels

  • Argument (1)
  • Class (1)
  • Defualt Argument (1)
  • Fact (1)
  • Factorial (1)
  • Item (1)
  • OOCP Material (1)
  • Pass by address (1)
  • Pass By argument (1)
  • Recursive Function (1)

Contributors

  • Dr. Parag Shukla
  • Vishal Joshipura
  • vaibhav

Pages

  • Home
Copyright © 2010 Object Oriented Concepts and Programming