+ 2
Create a timer program that will take the number of seconds as input, output the remaining time and countdown to 0.
Create a timer program that will take the number of seconds as input, output the remaining time and countdown to 0. You need to output every number, including 0.
5 Answers
+ 1
Heya, I got the right answer using this but i think there are better ways to do it
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int x;
int r;
for (x = n; x > 0; x--)
{ cout << x << endl;
r = x % 5;
if (r == 0 )
{cout << "Beep"<< endl;}
}
return 0;
}
+ 3
Use a for loop.
int seconds = 7; //for example
for(seconds; seconds >=0; seconds--)
{
std::cout << seconds;
}
+ 1
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int x;
int r;
for (x = n; x > 0; x--)
{ cout << x << endl;
r = x % 5;
if (r == 0 )
{cout << "Beep"<< endl;}
}
return 0;
}
+ 1
#include <iostream>
using namespace std;
int main()
{
int seconds;
cin >> seconds;
while (0 <= seconds){
cout << seconds << endl;
seconds--;
}
return 0;
}
0
what is the program?