i have no idea, tranlating psuedo code.

How can I translate this into a program?

Set a Boolean variable "first" to true.

While input value is not negative

If first is true

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.
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.
Something like this?
We might need more information to flesh out that code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>

using namespace 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;

}
Last edited on
what does it mean to set the minimum to the input value?
Make a variable called minimum and set it to the value that the user entered.
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);



}



return 0;

}
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.
Topic archived. No new replies allowed.