+ 3
Task 21 c++
Please explain difference. https://code.sololearn.com/cCbiwCzG7FFz/?ref=app
8 Antworten
+ 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
+ 2
You are using "beep"
But solution required to use "Beep"
Case sensitive matters..
+ 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.
+ 1
So those variants the same, but how it could works in lager programm or maybe some facts which is better to use?
+ 1
Thanks
+ 1
You're welcome..
0
I didnt ask about why it doesnt work, i asked about difference of those 2 variants
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;
}