+ 3

I Already Try So Hard,But It Always Wrong

I Don't Know Where I'm Wrong Here,I Tried So Many Times But I Still Can't Pass This Code Project,My Code Was This #include <iostream> using namespace std; int main() { int n; cin >> n; //your code goes here while(n > 0){ cout << n << endl; n--; } if(n %5==0){ cout << "Beep" << endl; } return 0; } If My Code Is Actually Not Relevant,Can Anyone Tell Me What's The Right Code?

8th Dec 2021, 1:48 AM
Lidya Reine
Lidya Reine - avatar
1 Respuesta
+ 11
In each condition n%5 ==0 beep should be print but your while loop ended before if condition you need to write this complete if condition inside loop body #include <iostream> using namespace std; int main() { int n; cin >> n; //your code goes here while(n!=0){ cout << n << endl; if(n %5==0){ cout << "Beep" << endl; } n--; } return 0; }
8th Dec 2021, 2:01 AM
A S Raghuvanshi
A S Raghuvanshi - avatar