help plz......

plz help me to solve this problem... create a c++ program using while and for loop that will output:
x is not between 1 and 4
x is one
x is two
x is three
x is four
x is not between 1 and 4..


THANKS a lot.....
I don't understand you're trying to to.
If you want to print that, just do this:

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>

int main()
{
    cout << "x is not between 1 and 4\n"
            "x is one\n"
            "x is two\n"
            "x is three\n"
            "x is four\n"
            "x is not between 1 and 4\n";
return 0;
}
Last edited on
my professor said that i need to use while and for loop......
No, that's not what your prof told you. Your prof told you to do this:

Write a program that does the following:

1) Reader user input into a variable x
2) Behave differently according to the value of x:
2.1) x=1: print "x is one".
2.2) x=2: print "x is two"
2.3) x=3: print "x is three"
2.4) x=4: print "x is four"
2.5) If neither of the above is true, print "x is not between 1 and 4"
3) Go back to 1

Implement this using a while or a for loop.
Last edited on
uhhhmmm.. u have a point.. can u do the code plz... i will try.. :D
closed account (1vRz3TCk)
Do the code yourself and ask specific questions when you get stuck.
closed account (zb0S216C)
carl24mvp wrote:
uhhhmmm.. u have a point.. can u do the code plz... i will try.. :D (sic)

And what would you would learn? You would learn nothing.

Wazzak
i dont know how to do... so hard... headache.... awwww.ww.....
closed account (1vRz3TCk)
i dont know how to do... so hard... headache.... awwww.ww.....

Are you going to hold your breath until you turn blue?
Think of the structure of your program first.

while program is running{
take user input and asign to variable
if variable == this: do this
else if variable == this: do this
...
else: do this
}

Is this what you are trying to acheive?
Topic archived. No new replies allowed.