Assume that x is already defined as being of type char Writ

Assume that x is already defined as being of type char . Write a single expression that will return true if x is odd. [Note that this compiler doesn\'t accept binary constants , so use hexidecimal instead. I.e., for 0b00111111 use 0x3F.]

Solution

#include <stdio.h>      /* printf */
#include <stdlib.h>     /* strtol */
int main ()
{
char hex[] = \"0x1A\";                           // hexadecimal number equivalent to 26
strtol (hex,NULL,0) & 1 ? printf(\"ODD\"):printf(\"EVEN\");       // strtol converts hexadecimal to decimal & binary operator checks it it\'s odd or not.
return 0;
}

/*

sampleoutput

ODD

*/

Assume that x is already defined as being of type char . Write a single expression that will return true if x is odd. [Note that this compiler doesn\'t accept b

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site