0

Help me out and solve the program

https://www.sololearn.com/coach/270?ref=app

17th Oct 2020, 1:02 AM
Adnan Rafique
Adnan Rafique - avatar
4 Answers
0
https://www.sololearn.com/coach/270?ref=app
17th Oct 2020, 1:08 AM
Adnan Rafique
Adnan Rafique - avatar
0
#include <iostream> using namespace std; int main() { int seconds,a; a=0; while(a<=60) cin>>seconds; cout<<"--a"<<endl; return 0; }
17th Oct 2020, 1:09 AM
Adnan Rafique
Adnan Rafique - avatar
0
Thanks.in the body of function you used not gate why? Can you explain the whole function to clear my concept.
17th Oct 2020, 3:29 AM
Adnan Rafique
Adnan Rafique - avatar
0
Here's my attempt (AC), #include <iostream> using namespace std; int main() { int sec; cin >> sec; while(sec+1) cout << sec-- << "\n"; return 0; } Simple and efficient enough. Why sec+1? So when it reaches 0, it still being printed out, otherwise the condition will be evaluated as false. Why sec--? As the problem implicitly says "Print it decreasing until it reaches 0, but also print the number 0", not that I use post-decrement instead of pre-decrement because I need the value *before* getting decremented.
17th Oct 2020, 3:53 AM
LastSecond959
LastSecond959 - avatar