Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Benneb10 on February 08, 2017, 09:11:10 pm

Title: please help me with if then statements
Post by: Benneb10 on February 08, 2017, 09:11:10 pm
this is probably a simple fix, but I'm trying to use if-then statements to set up a calculator that asks what type of equation and all that, I spent a while on it and I'm tired, so this is probably a simple fix but here is the code

Code
#include <iostream>

using namespace std;

int main()
{
    float x;

    cout << "please enter 1 or 2: ";
    cin >> x;
    if ((x = 1)){
        float x;

        cout << "1please enter 0, 2, 3, or 4: ";
        cin >> x;
        {if ((x = 1)){
                cout << "Fix this ####, 1.0";//this is only here to let me know if i figured out the problem, and if i solved it.
            return 0;
            }
            else if ((x = 0)){
                cout << "yay, your not a dumbass, unless this went after the second imputs, 1.1";
            return 0;
            }
            else if ((x = 2)){
                cout << "yay, your not a dumbass, unless this went after the second imputs, 1.2";
            return 0;
            }
            else if ((x = 3)){
                cout << "yay, your not a dumbass, unless this went after the second imputs, 1.3";
            return 0;
            }
            else if ((x = 4)){
                cout << "yay, your not a dumbass, unless this went after the second imputs, 1.4";
            return 0;
            }
        }
    }
    else if ((x = 2)){
        float x;

        cout << "2please enter 1, 2, 3, or 4: ";
        cin >> x;
        {if ((x = 1)){
                cout << "yay, your not a dumbass, unless this went after the second imputs, 2.1";
            return 0;
            }
            else if ((x = 2)){
                cout << "yay, your not a dumbass, unless this went after the second imputs, 2.2";
            return 0;
            }
            else if ((x = 3)){
                cout << "yay, your not a dumbass, unless this went after the second imputs, 2.3";
            return 0;
            }
            else if ((x = 4)){
                cout << "yay, your not a dumbass, unless this went after the second imputs, 2.4";
            return 0;
            }
        }
    }
}
please help and I will be very gratefull.

PS. I can not spell, so any spelling errors please don't judge me for
PPS. I looked on Google, but I am bad at figuring out what to search, and so if it on google how to help, please just post the link and I will try to look at it and reply whether or not I figured it out.
Title: Re: please help me with if then statements
Post by: Benneb10 on February 08, 2017, 09:34:38 pm
I have slightly modified the code, just some of the text

Code
#include <iostream>

using namespace std;

int main()
{
    float x;

    cout << "please enter 1 or 2: ";
    cin >> x;
    if ((x = 1)){
        float x;

        cout << "1please enter 0, 2, 3, or 4: ";
        cin >> x;
        {if ((x = 1)){
                cout << "Fix this ####, 1.0";
            return 0;
            }
            else if ((x = 0)){
                cout << "yay, your not a dumbass, x = 0, 1.1";
            return 0;
            }
            else if ((x = 2)){
                cout << "yay, your not a dumbass, x = 2, 1.2";
            return 0;
            }
            else if ((x = 3)){
                cout << "yay, your not a dumbass, x = 3, 1.3";
            return 0;
            }
            else if ((x = 4)){
                cout << "yay, your not a dumbass, x = 4, 1.4";
            return 0;
            }
        }
    }
    else if ((x = 2)){
        float x;

        cout << "2please enter 1, 2, 3, or 4: ";
        cin >> x;
        {if ((x = 1)){
                cout << "yay, your not a dumbass, x = 1, 2.1";
            return 0;
            }
            else if ((x = 2)){
                cout << "yay, your not a dumbass, x = 2, 2.2";
            return 0;
            }
            else if ((x = 3)){
                cout << "yay, your not a dumbass, x = 3, 2.3";
            return 0;
            }
            else if ((x = 4)){
                cout << "yay, your not a dumbass, x = 4, 2.4";
            return 0;
            }
        }
    }
}
Title: Re: please help me with if then statements
Post by: BlueHazzard on February 08, 2017, 09:46:17 pm
ok, i think i will rage quit now...

1) YOU agreed by signing in to this forum that you agree with the rules. There is cleaerly written that programming questions are not allowed at this forum... To neglect the rules will result in a ban. Your question is 100% programming related 0% codeblocks related

2) This is rhetoric: WHAT IS YOUR QUESTION....
 ..... just by looking at your code i see the obvious problem... but i don't see any concrete question in your post, what your problem is...

3) READ THE WARNINGS OF YOUR COMPILER. WARNINGS ARE THERE FOR A REASON....
Title: Re: please help me with if then statements
Post by: stahta01 on February 08, 2017, 11:04:18 pm
Link to the rules of this site http://forums.codeblocks.org/index.php/topic,9996.0.html (http://forums.codeblocks.org/index.php/topic,9996.0.html)
Title: Re: please help me with if then statements
Post by: Jenna on February 09, 2017, 09:56:18 pm
Topic locked, everything else is said by BlueHazzard and stahta01 .