Почему код не работает | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Почему код не работает

#include <iostream> using namespace std; int main() { int num = 1; while (num < 6) { cout << "Number: " << num << endl; num=num+1; } return 0; }

22nd Jul 2021, 9:01 AM
Slavik
2 Answers
+ 7
Slavik , the does work properly, it outputs the numbers from 1 up to 5. if you expect to get also the number of 6, you should use the conditional: while (num <= 6) happy coding!
22nd Jul 2021, 9:53 AM
Lothar
Lothar - avatar
+ 1
Где ошибка ?
22nd Jul 2021, 9:01 AM
Slavik