Ask your own question, for FREE!
Computer Science 14 Online
OpenStudy (anonymous):

C program not functioning with "||" File Attached

OpenStudy (rsmith6559):

No file, so just a guess. "||" is "or" in a conditional statement. Bitwise "or" is '|'.

OpenStudy (anonymous):

rsmith6559 is correct, || does in fact mean "or" in a conditional statment while programming c. I cannot confirm bitwise

OpenStudy (anonymous):

yup . . both are right. . in C we have || to denote the "or" conditional statement for example: a or b " will be written as a || b " in C

OpenStudy (anonymous):

must have deleted the file by mistake, i have re uploaded the file

OpenStudy (rsmith6559):

AFAIK, conditionals like that should be written: if( ( a == b ) || ( c == d ) || ( e != f ) ) { /* try again */ } So that the comparisons are done, and then the results of the comparisons are or'd together. Or does short-circuit.

OpenStudy (anonymous):

thanks rsmith6559, that has helped but now im getting a complier error, When compiled and run the program crashes stragoght after you have the input w || W

OpenStudy (anonymous):

you have to put w||W in quotes. like: if(user_choice == 'w'||'W') { }

OpenStudy (rsmith6559):

if( ( user_choice == 'w' ) || ( user_choice == 'W' ) ) { } The comparisons are to the letter, the || is for the results of the comparisons.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!