You do know we can see your post history, right? And that you posted the exact same thing before?
Just rationally think about what your pseudocode is defining. For example:
Set a Boolean variable "first" to true
Is going to look very simple, like such: bool first = true;
The rest of your code should follow suit. Because you already have the pseudocode, all that's really left is the syntax. You'll want to at least attempt translating it a bit. We can help you if you get stuck along the way with syntax or logic issues or w/e.
#include <iostream>
usingnamespace std;
int main() {
bool aValue = true;
string input; // string because you can read any value into it.
while (input <= 0) {
/*
If input value is positive
Set the minimum to the input value.
Set first to false.
Else
Output 0 is not a valid input.
Else
If input value is positive
If the input value is less than the minimum
Set the minimum to the input value.
Else
Output 0 is not a valid input.
If first is true
Output no valid numbers were input so there is not a minimum value.
Else
Output the minimum value.
*/
}
return 0;
}
i keep geting illegal else statements used.
what am i doing wrong?
#include <iostream>
using namespace std;
int main()
{
bool first = true;
string input;
int i = 0;
cout << " This progam will find the minimum positive number input." << endl;
cout << " Entering a negative number will stop the input." << endl;
cout << " Enter a positive number (negative number to quit): ";
cin >> i;
while (i <= 0)
{
if (i >= 0)
int min = i;
else (0 != i);
cout << i << " is not a valid input" << endl;
if (bool first = false);
else (i == 0);
break;
else;
if (i < 0);
int min = i;
else (0 != i);
cout << i << " is not a valid number. " << endl;
if (bool first = false);
I would seriously suggest reading this very carefully http://www.cplusplus.com/doc/tutorial/control/
Example problems in your code are declaring a variable in the if statement (don't put the type before it if you've already declared it). Don't use semicolons after ifs. Also use curly braces after ifs and elses.