C program not functioning with "||" File Attached
No file, so just a guess. "||" is "or" in a conditional statement. Bitwise "or" is '|'.
rsmith6559 is correct, || does in fact mean "or" in a conditional statment while programming c. I cannot confirm bitwise
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
must have deleted the file by mistake, i have re uploaded the file
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.
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
you have to put w||W in quotes. like: if(user_choice == 'w'||'W') { }
if( ( user_choice == 'w' ) || ( user_choice == 'W' ) ) { } The comparisons are to the letter, the || is for the results of the comparisons.
Join our real-time social learning platform and learn together with your friends!