#include <iostream>
usingnamespace std;
int turis(int l=1, int w=1, int h=1);
int main()
{
int l;
cout << "turis(l)";
cin >> turis (l);
cout << volume();
}
int turis(int l, int w, int h){
return l*w*h;
}
Was watching some bucky's tutorials. He basically was showing here passing values of variables to function by cout << turis(5,4), what I wanna do is to make user input those values in compiled cmd, not in the source code itself... What's ther proper code standing for it?
lets say we have a function to add two numbers together.
1 2 3 4
int addTwo(int a, int b)
{
return a + b
}
To have the user input the 2 numbers to add we would do something like this.
1 2 3 4 5 6 7 8 9 10 11 12 13
int numberOne;
int numberTwo;
int total;
cout << "Enter Number One: ";
cin >> numberOne;
cout << "Enter Number Two: ";
cin >> numberTwo;
// This is the function to add them notice how we use the variables that stored
// The users input.
total = addTwo(numberOne, numberTwo);
That should show you the basic's how how to use user input int a function. Obviously there is many different and more advanced ways, but I'm not sure if you are ready for them yet. Just keep on learning and practicing. Also I would recommend maybe using some other resources to study C++ along with Bucky's video's (Personally I don't think they are good). You could use the tutorial here or just do a search for good beginner C++ tutorials/books and you should get many threads on the subject.