- 4

c++ countdown program

Pls do solve and send anyone

19th Mar 2021, 10:09 AM
vijayalakshmi T.G.
vijayalakshmi T.G. - avatar
18 ответов
+ 5
vijayalakshmi T.G. check it while(n>0){ if(n%5==0){ cout<<n<<endl<<"Beep"<<endl; /* it will first print the number(multiple of 5) then will print beep */ n--; /* decreasing by 1*/ } else{ cout<<n<<endl; /* if not multiple of 5 then will print only that number*/ n--; } }
19th Mar 2021, 10:22 AM
TOLUENE
TOLUENE - avatar
+ 5
Code: (Works) #include <iostream> using namespace std; int main() { int n; cin >> n; while(n>=1) { if(n%5==0){ cout<<n <<"Beep"<<"\n";} else{ cout<<n; } n--; } return 0; }
29th Aug 2022, 7:14 PM
A C
+ 4
int main() { int n; cin >> n; while(n>=1) { if(n%5==0){ cout<<n <<"Beep"<<"\n";} else{ cout<<n; } n--; } return 0; }
19th Mar 2021, 10:25 AM
Atul [Inactive]
+ 1
While(n>=1) { if(n=n%5); Cout <<"Beep"; n--; }
19th Mar 2021, 10:20 AM
vijayalakshmi T.G.
vijayalakshmi T.G. - avatar
+ 1
= is an assignment operator use == instead of that
19th Mar 2021, 10:22 AM
Atul [Inactive]
+ 1
Ok thank you
19th Mar 2021, 10:23 AM
vijayalakshmi T.G.
vijayalakshmi T.G. - avatar
+ 1
These are some necessary changes that you should bring in your code
19th Mar 2021, 10:25 AM
Atul [Inactive]
+ 1
#include <iostream> using namespace std; int main() { int n; cin >> n; while (n>=1){ if (n%5==0){ cout << n << endl << "beep" << endl;} else { cout << n << endl; } n--; } return 0; } That works good, but i couldn't finish exercise because after number 1 programme still doing new blank line and app don't count it, anyone have some solution?
19th Aug 2022, 9:16 AM
Damian Zduński
Damian Zduński - avatar
0
vijayalakshmi T.G. then show us your code .we can help you more accurately then .
19th Mar 2021, 10:17 AM
TOLUENE
TOLUENE - avatar
0
Please post your try
19th Mar 2021, 10:19 AM
Atul [Inactive]
0
// HI THERE!! #include <iostream> using namespace std; int main() { int n; cin >> n; while( n >= 1 ) { if( n%5 == 0 ){ cout << n << '\n' << "Beep" << endl; } else { cout << n << '\n' << endl; } n--; } return 0; }
13th Sep 2022, 2:03 PM
Agung Wiranata
0
short and good! #include <iostream> using namespace std; int main() {int n; cin >> n; while(n>=1) {if(n%5==0) {cout<<n <<"Beep"<<"\n";} else{cout<<n;} n--;} return 0;}
6th Oct 2022, 11:06 AM
Marcel Krättli
0
#include <iostream> using namespace std; int main() { int n; cin >> n; while (n>0){ cout << n <<endl; if (n%5==0){ cout << "Beep" << endl; } n--; } return 0; }
15th Oct 2022, 7:46 PM
Ali hegazy
Ali hegazy - avatar
0
#include <iostream> using namespace std; int main() { int n; cin >> n; //your code goes here for (int i=n; i>0; i--){ cout << i <<endl; if (i%5==0){ cout<<"Beep"<<endl; } } return 0; }
3rd Nov 2022, 1:08 AM
Mike
Mike - avatar
0
It seems there is only one way and when I see it I understand it and it is easy but how (from so many functions and variations) do I ever know I have to use this method exactly? I tried to do n>0 first after if and then modulus of 5 in else but I wouldn't have guessed to start with modulus after if and then do the main part in else phase. I would be natural to me to make bigger part after if and smaller part after else but here it is other way around. My problem seems to reoccur that I know the methods but don't know which one to pick and how to twist them for that specific way that I just don't see.
14th Feb 2023, 9:52 AM
Adam Olejniczak
19th Mar 2021, 10:13 AM
你知道規則,我也是
你知道規則,我也是 - avatar
- 1
I had written the code but i don't know where i did mistake
19th Mar 2021, 10:16 AM
vijayalakshmi T.G.
vijayalakshmi T.G. - avatar