- 2

can someone help me with the countdown challenge? am stuck, please!

I want the word "beef" to appear AFTER every multiple of 5. but my code shows it BEFORE. Here is the code (cpp) #include <iostream> using namespace std; int main() { int n; cin >> n; for (; n>0; ) { cout<<n<<endl; n--; if (n%5==0) cout<<"beef"<<endl; } return 0; }

24th Oct 2021, 1:58 PM
Aminu Alhaji Adamu
Aminu Alhaji Adamu - avatar
2 Antworten
+ 2
Alameen There is Beep not beef First print number Then print Beep if number is multiple of 5 Then do decrement in n.
24th Oct 2021, 2:03 PM
A͢J
A͢J - avatar
0
Please always tag the language you're asking about. https://code.sololearn.com/W3uiji9X28C1/?ref=app
24th Oct 2021, 5:18 PM
Simon Sauter
Simon Sauter - avatar