+ 2
Simple problem
Simple problem? Program reads two-digit number and prints every digit separately, separated by a space. Input One integer from 10 to 99 including. Output Two digits separated by Input example 23 Output example 2 3
13 Respostas
+ 4
@Chapay I posted up code with your exact specifications that you asked for. It ensures the input is within the range, and it'll loop to obtain new input until the correct range is inputted. If input is within range, it'll print it separated by a whitespace.
Just note, since it's SoloLearn compiler, it isn't going to prompt you for input again. As such, the loop will keep using the same input because of SoloLearn. However, in another compiler that isn't restricted, it'll work as intended.
Hope it helps. Good luck to you in your learning.
+ 2
https://www.sololearn.com/Discuss/854652/simple-problem
Give me a moment and I'll post my version of it, if you're simply just trying to get another take on the answer.
+ 2
hope this helps
https://code.sololearn.com/cadIXfhd48ru/?ref=app
+ 2
finally thank you very much
+ 2
only one suggestion
try on ur own for sometime
if u still didn't get it don't bother to ask
HAPPY CODING!!!
AND WELCOME SL COMMUNITY!!!
+ 2
thank you you are really helpful
+ 2
netkos's method is much satisfactory than mine
+ 2
anyway both are correct
+ 2
Here you go, as promised. Hope that helps. It's rough idea of what you're looking for.
https://code.sololearn.com/cxFMCyF5pI9j/#cpp
#include <iostream>
using namespace std;
void getEachNum(int number)
{
if(number >= 10)
getEachNum(number / 10);
int num = number % 10;
cout << num << ' ';
}
int main() {
int userInput = 0;
while(true){
cout<<"Please enter a number (10-99): "<<endl;
cin>>userInput;
if(userInput < 10 || userInput > 99) {
cout<<"Number out of range! Try again."<<endl;
continue;
} else {
getEachNum(userInput);
break;
}
}
return 0;
}
+ 1
sorry i am really new here i started yesterday i really dont kjow what i am doing
+ 1
following you :)
0
I need it in c ++
0
LOL, I wrote this on C++.