Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

i needz help (C++)

Name: Anonymous 2007-12-20 11:59

hay guyz.

Anyways, I new to programming, I need to know how to use the || operator properly.

ie.

if number is not 3 or 4. ask for another input.
could someone give me an example?
not sure at what point in a loop it goes at.
assuming it could be in a do ( cout << "plz enter valid number: " cin >> number ) while (number != 3 || 4) or something?
but that doesn't work.
It keeps telling me that my number is invalid.

Cheers,
anon.

Name: Anonymous 2007-12-20 12:14

!!!(~n  == ~(((!3)<<1)|1) || n == 4)

Name: Anonymous 2007-12-20 12:14

When your alternatives are in a continuous range, it's easier to do it like this:

while (3 <= number <= 4)

It's also more scalable as you don't have to add more code even if the range was 100 numbers long.

Name: Anonymous 2007-12-20 12:16

SEPPLES ? !

Name: Anonymous 2007-12-20 12:23

>>3 That makes some sense, but what happens when it's numbers like 4 and 6, without 5?
ie. input must be either 4 or 6. if you enter any other number, it should show an invalid message.

Name: Anonymous 2007-12-20 12:49

>>5
Then use ||. It's just like in logic, but I believe it short circuit evaluates. So something like if (1 || imUsingSepples()) {} would never evaluate imUsingSepples(). Any side effects of that function (dick in your ass, &c.) will not occur.

And || is a connective, not a predicate. You can only use it on true/false values. if (number = 3 || number = 4) {}

If you want to make several comparisons against the same integer, use a switch.
[code]switch (number) {
  case 4:
  case 6:
    cout << "Good job, faggot.";
    break;
  default:
   cout << "Ur a faggot.";
}

Name: Anonymous 2007-12-20 12:50

>>3
DON'T HELP HIM!

Name: Anonymous 2007-12-20 12:51

>>6
DON'T
HELP
HIM!!!!

Name: Anonymous 2007-12-20 12:52

>>8
Teaching him how to use Sepples is hardly helping. It's like giving someone AIDS of the brain.

Name: Anonymous 2007-12-20 12:53

>>3
a <= b <= c is always true if c >= 1, faggot.
>>6
learn C faggot.

Name: Anonymous 2007-12-20 12:55

>>10
5 <= 6 <= 1

GOOD WORK FAGGOT

Name: Anonymous 2007-12-20 12:58

>>10
YOU HAVE BEEN TROLLED, I think.

Name: Anonymous 2007-12-20 13:40

>>6
if (number = 3 || number = 4) {}

Wait.. What?

Name: Anonymous 2007-12-20 13:44

>>9 Sepples is bad?
I not tried lisp, because I'm not expert enough.
I'll try sometime.

C++ seems to be easiest to pick up for now.

Name: Anonymous 2007-12-20 14:01

>>14
no

Name: Anonymous 2007-12-20 14:02

>>15 lazy troll.
why no?

Name: Anonymous 2007-12-20 14:03

>>16
Just trolling, just no.

Name: Anonymous 2007-12-20 14:04

idorts...

Name: Anonymous 2007-12-20 15:21

>>18
Go back to /v/, you don't belong in your boards.

Name: The Sussman 2007-12-21 4:05

It means or, you idiot

Name: Anonymous 2007-12-21 7:27

>>20
Would be a reply to...?

Name: Anonymous 2009-03-06 8:33

The scope of a   BITCH BASH I   AM TCSH BASH   IS PIG DO   YOU WANT PYTHON   PHP etc run   on Windows but   they also run   the same code   on Linux FreeBSD   Solaris and a   few small things   Like once I   get some time   what could we   do to fix.

Name: Anonymous 2010-11-15 2:52

Name: Anonymous 2011-02-04 14:46

Don't change these.
Name: Email:
Entire Thread Thread List