I tried making a program where it tells the user to input the "secret password". If you write any number that is not "0", it will just repeat itself and keep asking for the password.
If you DO write 0, it will countdown from 10 to 0 and "self-destruct".
I can't seem to get the countdown working. I can get it working independently, but not in this program. please help!
#include <iostream>
using namespace std;
int main()
{
int n;
int countdown = 10;
do{
cout << "Please enter the secret number\n";
cout << "WARNING, DO NOT INPUT 0; it WILL self-destruct.\n";
cin >> n;
cout << "You have entered " << n << ".\n";
}
while ( n != 0 );
{
int main()
{
int n;
int countdown = 10;
do{
cout << "Please enter the secret number\n";
cout << "WARNING, DO NOT INPUT 0; it WILL self-destruct.\n";
cin >> n;
cout << "You have entered " << n << ".\n";
}
while ( n != 0 );
{ // this is a block scope you have here... not a loop.
cout << "PROGRAM FAILTURE, SELF DESTRUCT IN: \n";
countdown = 10;
while ( countdown > 0 ); // this while starts and ends here
cout << "t-" << countdown << "\n";
--countdown; // this is not part of the loop on line 17
} // end of block scope
while ( countdown > 0 ); // will this ever evaluate to true ?
{ // another block scope.... not part of the while loop you need to stop using ';' so much
cout << "KABLAMMMM... you lost an arm\n";
system ("PAUSE");
return 0;
}
}
the ; is used to end a command
while (true); <--- this starts and stops here anything afterwards is not part of the loop.