Skip to content

Instantly share code, notes, and snippets.

@AhmedHelalAhmed
Created December 2, 2017 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AhmedHelalAhmed/149ed933fb5c0c41df317ae70fc28e32 to your computer and use it in GitHub Desktop.
Save AhmedHelalAhmed/149ed933fb5c0c41df317ae70fc28e32 to your computer and use it in GitHub Desktop.
default argument condition
#include <iostream>
using namespace std;
/*
int f(int x,int y=1,int z);
it will generate error
when default argument starts it must be to the end
*/
int f(int x,int y=1,int z=1);
int main()
{
int v1,v2,v3;
v1=f(1,2,3);
cout<<v1<<endl;
v2=f(3,2);
cout<<v2<<endl;
v3=f(2);
cout<<v3<<endl;
return 0;
}
int f(int x,int y,int z)
{
cout<<"x= "<<x<<endl;
cout<<"y= "<<y<<endl;
cout<<"z= "<<z<<endl;
return x*y*z;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment