+ 3

Task 21 c++

Please explain difference. https://code.sololearn.com/cCbiwCzG7FFz/?ref=app

1st May 2022, 2:05 PM
Ivan Horlenko
8 ответов
+ 2
For loop is better to use if you know the number of iterations needed in prior like fixed iterations.. And use while loop, if you don't know when to stop loop.. Like loop should iterate until a condition met.. Use search, you can find many other example I guess.. Hope it helps
1st May 2022, 2:40 PM
Jayakrishna 🇮🇳
+ 2
You are using "beep" But solution required to use "Beep" Case sensitive matters..
1st May 2022, 2:08 PM
Jayakrishna 🇮🇳
+ 1
That's what the difference between those two in outputting.. Everything else works same... You mean the logic in implementation? Try to explain it clearly.. First one uses the while loop to implement logic but later uses the for loop... No other differences.. If this is not what you looking then explain with specific details with clarity. Hope it helps.
1st May 2022, 2:29 PM
Jayakrishna 🇮🇳
+ 1
So those variants the same, but how it could works in lager programm or maybe some facts which is better to use?
1st May 2022, 2:33 PM
Ivan Horlenko
+ 1
Thanks
1st May 2022, 2:42 PM
Ivan Horlenko
+ 1
You're welcome..
1st May 2022, 2:48 PM
Jayakrishna 🇮🇳
0
I didnt ask about why it doesnt work, i asked about difference of those 2 variants
1st May 2022, 2:23 PM
Ivan Horlenko
0
#include <iostream> using namespace std; int main() { int n; cin >> n; while(n > 0) { if (n % 5 != 0) cout << n << endl; else { cout << n << endl; cout << "Beep" << endl; } n--; } return 0; }
1st May 2022, 4:42 PM
Илья
Илья - avatar