#include<iostream>
usingnamespace std;
int main()
{
int n;
int abort;
cout << "Input the number you would like to start the countdown from" << endl;
cout << "press Enter, then input your abort number!!!" << endl;
cin >> n >> abort;
If (abort>n)
{
cout << "ERROR!!! Make countdown > abort\n Reenter now... \n";
cin >> n >> abort;
}
Do
{
cout << n << endl;
If (n == abort)
cout << "ABORTED!!!"}
}While (n>0)}
What is the matter with this, I want the user to decide when to abort the countdown, please help :)
#include<iostream>
usingnamespace std;
int main()
{
int n;
int abort;
cout << "Input the number you would like to start the countdown from" << endl;
cout << "press Enter, then input your abort number!!!" << endl;
cin >> n >> abort;
if (abort>n)
{
cout << "ERROR!!! Make countdown > abort\n Reenter now... \n";
cin >> n >> abort;
}
do
{
cout << n << endl;
if (n == abort)
cout << "ABORTED!!!"}
--n;
}while (n>0);
}
#include<iostream>
usingnamespace std;
int main()
{
int n;
int abort;
cout << "Input the number you would like to start the countdown from" << endl;
cout << "press Enter, then input your abort number!!!" << endl;
cin >> n >> abort;
if (abort>n)
{
do // added do... while loop to get correct data
{
cout << "ERROR!!! Make countdown > abort\n Reenter now... \n";
cin >> n >> abort;
}while (abort > n);
}
while (n >= abort) // changed code here
{
cout << n << endl;
if (n == abort)
cout << "ABORTED!!!" << endl; // added line break here
--n;
}
return 0;
}