0

How to I make a multiple *5 loop

#include <iostream> using namespace std; int main() { int n; cin >> n; while (n >= 1){ cout << n << endl; n--; } if (n >= 1){ cout << "Beep" << endl; n%=5; } //your code goes here return 0; }

10th Jul 2022, 2:18 AM
Nik
1 Réponse
+ 5
Nik if condition should be inside while loop and there should be (n % 5 == 0) instead of (n >= 1) inside if condition. remove n %= 5 if (n % 5 == 0) { cout << "Beep"; } n--; should be after if block
10th Jul 2022, 3:59 AM
A͢J
A͢J - avatar