0

write a program to define a function with default argument. whenever the function needs default values of arguments,it should prompt the user to enter the default value. also display the default values.

we can create any function

2nd Jul 2016, 6:16 PM
akhil matcha
akhil matcha - avatar
5 odpowiedzi
0
void f(int v = NULL) { if (!v && v != 0) { cout << "Argument needed: "; cin >> v; } cout << v; } EDIT: Now it satisfies your last requirement.
2nd Jul 2016, 6:49 PM
Garme Kain
Garme Kain - avatar
0
thank you bro
2nd Jul 2016, 6:55 PM
akhil matcha
akhil matcha - avatar
0
Anyways, i have to ask, what is the purpose of this piece of code? It is supposed that the default values in functions are for exactly this purpose, so you dont have to write it, so, what is his purpose?
2nd Jul 2016, 6:57 PM
Garme Kain
Garme Kain - avatar
0
this the program given to me as an assignment in my university I was getting the logic but not able to write the code so I posted it that its
2nd Jul 2016, 7:00 PM
akhil matcha
akhil matcha - avatar
0
ntng more than that
2nd Jul 2016, 7:00 PM
akhil matcha
akhil matcha - avatar