Answer the question
In order to leave comments, you need to log in
How can I write this code so that it returns 00 and not 0?
Hello! I'm having a problem with an outgoing value in C++.
More: I am taking a course on Stepik on solving problems in C ++ and met the following task there: https://stepik.org/lesson/54364/step/3?auth=regist...
Everything is clear with the first output, but not with the second very. How can I make it output 12 and 00 instead of 12 and 0? Am I stupid or the creators of the course screwed up?
Thanks in advance)
#include <iostream>
using namespace std;
int main() {
int num = 0;
cin >> num;
int number1 = num/100;
int number2 = num%100;
cout << number1 << " " << number2 << endl;
return 0;
}
Answer the question
In order to leave comments, you need to log in
cout << number1 << ‘ ‘;
If (number2 < 10)
cout << ‘0’;
cout << number2;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question