+ 1
How do i connect two functions? *correction 'if,else'
Im brand new to all of this (going throught the tutorial) so i apologize if my vocabulary is incorrect, bear with me please. The code that i input to form a function following int main(), im curious how to connect two functions. Say i used a basic integer storing function (cin) to let user choose left or right (left = 0, right =1) coupled with and if then statement. How do i print the instructions to do just that, before they actually input the data. Sorry if confusing. Check out plygrnd 'down the road'
4 odpowiedzi
+ 7
Hello, I didn't understand your question at first but after I saw your code I get it.
So you want to print instructions before the user inputs data.
Don't worry, your code is just fine and working correctly
Test it in another location (e.g. Visual Studio or online compilers) other than Sololearn and you will see it working fine: A msg appears first than asks for input..
Sololearn compiler is a special case:
it asks first the user to input all the required inputs once each one in a new line.
It works the same for all languages here.
(Example:
int a, b;
cout << "Enter two positive numbers" << endl;
cin << a;
cin << b;
* When you Run this code on sololearn, it will ask you first to input a and b, so you enter something like this:
35 // a value will be 35
19 // b value will be 19
// each value in a new line
* After that the code will print to screen:
Enter two positives numbers
)
Summary: Your code is working as you want to (instructions first than input). It's just the behavior of sololearn compiler.
Hope I Helped ⭐
+ 1
If you are talking about how to do this (asking a user of smth, prompting user with a description before input) here in SLs playground... so, sorry, but it's not possible (this feature is unavailable). You should do it at your desktop/laptop with some c(++) compiler or may be in other app on your mobile device (CppDroid i.e. if I remember right, but anyway coding is more comfortable while you use laptop or desktop)
+ 1
Your code will already print your instructions before the user has to du the input.
If you are confused because the playground emediately asks for input after running the code, I guess it's just the way how the compiler is handling the code.
But if you type your code into an ordinary compiler like code::blocks and run it, your instructions will show up before the user gets asked to do bis input.
+ 1
Thank you!! The advice is perfect! 👌🏼