+ 1
Function with no return with parameters and default Arguments
This question is from Udemy, the question is to print a grocery list where you buy apples = 13 Mangoes = 3 and Oranges = 7 Can anyone code this out to me and explain it?
6 Respostas
+ 3
According to your requirement you can declare and initialize those variables inside the function itself and then print each of them.
Then you can call the function in your main method just with its name.
You don't need a return but a return type void to do the above.
+ 2
Post the link of your code with errors and we will help.
We don't write the whole code unless you show us what you have tried.
+ 2
Learn about functions or if you already know then kindly revisit it.
Now here you go.
https://code.sololearn.com/cRH4VKEQRw4b/?ref=app
+ 1
#include <iostream>
using namespace std;
void grocery_list (int apple = 12, int mango = 3,int oranges = 7);
int main ()
{
grocery list ();
return 0;
}
void (int apple, int mango, int oranges)
{
cout<< "Apple is:";
cout<< "Oranges is:";
cout<< "Mangoes is:"
}
0
Bro it would have been better if you could just code it out I am getting errors!
0
There you go.