+ 1

inspired by quiz

hello, to pass the test, you had to fill in some missing letters etc... well i saw cin and was curiouse to make it... i expected an pop up to show up but nothing happened.. some theories or ideas why the pop up didnt show? no compile errors or nothing... #include <iostream> using namespace std; int main() { int x; cin >> x; if(x > 20){ cout << "x is big" << endl; } if(x < 10){ cout << "x is all" << endl; } return 0; }

15th May 2017, 7:31 PM
Marlon De Gang
Marlon De Gang - avatar
4 Respostas
+ 12
According to the code, the console is waiting for user input. The user needs to give an integer input first. For example, if you type 25 in console, it will print "x is big". If you want to show a prompt message first, then include the following statement before cin, cout << "Enter a number : "; One more thing, SL code playground doesn't support taking multiple inputs on run time. It takes all the inputs before execution, and then shows the output.
15th May 2017, 9:00 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 11
Integer means whole number like 12, 10, 5, 500, -45, 0 etc. but x10, x etc. are not integers, that's why it stopped working :) Your program checks the numbers of ranges: greater than 20, or less than 10. So if you enter any input in between, like 10, 11, .....19, 20, it won't give any output.
15th May 2017, 9:29 PM
Shamima Yasmin
Shamima Yasmin - avatar
0
oh thx bit i writhen the code in cppdroid and have tried tje following inputs: 10, 25, x, x10, x 10. on the first two 8nputs the progams stops but on the other inputs it said x is all
15th May 2017, 9:21 PM
Marlon De Gang
Marlon De Gang - avatar
0
aha, i see why it said "x is all" because i forgotten to write "sm" to complete the word "small"... oke the program works fine but there is no pop up like the cin gave on preveous lessons in try it now but oke that is just a detail... thx for ur attention and ill try and follow you once in a while. regards marl9n
15th May 2017, 9:41 PM
Marlon De Gang
Marlon De Gang - avatar