Anyone here an expert in C++ or programming?

KMA

Registered User
Forum Member
May 25, 2003
745
2
0
I might be able to help walk you thru something if you post your questions.
 

dr. freeze

BIG12 KING
Forum Member
Aug 25, 2001
7,170
8
0
Mansion
need to know what the following operators do:

XOR ^^
!=
!
~

also need to know how conditional statements work.....

also am wondering if there is a "not" operator

thanks....
 

KotysDad

Registered User
Forum Member
Feb 6, 2001
1,206
7
38
XOR (^) is an exclusive OR......same as a mod 2 sum. In other words...
1^1 = 0
0^0 = 0
1^0 = 1
0^1 = 1

!= is "not equal". If (a does not equal b) then do the following, in C you would write it IF (a != b)

! is NOT. For example to say if (not a) then do the following step, you would write...

IF (!a)
THEN do the following step

As far as conditional statements, there are IF/THEN/ELSE statements........there are CASE statements, and probably others.

IF (a==b)
THEN (do following)
ELSE (do this instead)

With an IF/THEN/ELSE if the condition in the IF statement is TRUE, then you execute the steps in the THEN. If the statement in the IF condition is FALSE, then you execute the statements in the ELSE.

There are other conditionals such as a CASE (or is it SWITCH) statement. Anyway, You use it to execute a certain line of code based on the value of the CASE condition. For example, if you wrote a program to draw a number at random from 1 to 10 and perform some function based on that number, you would write

Case (random number)

1: perform function 1
2: perform function 2
3: perform function 3
etc.....

Another conditional is a WHILE statement,

generate random number
WHILE (number < 5)
perform this function
generate another number

This conditional performs a certain function until the generated number is bigger than 5, then it goes on the next line of code.

Most beginner programming books on C have easy to follow chapters on learning C and the various statements though, and do alot better job of explaining it than I just did. lol
 
Last edited:

KotysDad

Registered User
Forum Member
Feb 6, 2001
1,206
7
38
Got a bit more info....

~ is a one's complement operator. It is used to change a variable from a 1 to 0 or True to False or 0 to 1 or False to True. It's mainly used in programming cipher algorithms in cryptographic implementations - which I do alot of - but I have always used the XOR to change a 1 to a 0. XOR a bit value with a 1 in essence performs a one's complement.

The XOR operator is a single ^. The only ^^ operator I am familiar with is a power function. Computing 2 raised to the 3 power is 2^^3.
 

dr. freeze

BIG12 KING
Forum Member
Aug 25, 2001
7,170
8
0
Mansion
thanks a lot man!!! you are a great help!!!

working on a project right now am trying to learn all this stuff....pretty overwhelming when you have to learn while doing it....lol....

wish i majored in CPU science in college....would have been so useful instead of my physics degree :(
 
Bet on MyBookie
Top