Question: Understanding Operators This assignment is to help you understand the various assignment and operators in the C language. First try to understand and answer in
Understanding Operators
This assignment is to help you understand the various assignment and operators in the C language. First try to understand and answer in the comment field by hand. Then cut and paste this code to the IDE and compile/link and execute the code in the debugger to validate your answers. If you got your answer wrong, use the computer debugger and lecture slides to understand how the operator works.
Be aware that you may see these on a test.
Submit only the C-code and as Hw1.c. Include a header comment which contains your name. Minus 5 points if this is not followed.
When required in the comment field 0x, answer with the value in hexadecimal.
Be sure to fix any compilation errors. You are allowed to put newlines between the statements to help you step through the code using the debugger. For example:
Original code: j=41; i=j++; //i=
Newline: j=41;
i=j++; //i=
#include
void main()
{
char j, i;
unsigned char uj, ui; //char are byte size identifiers
float fj = 10.0, fi = 10.00977, fd;
j=-21; i=-j; // i=
ui=127; i=++ui; // ui= i=
ui=0; --ui; // ui=
j=41; i=j++; // i=
j=41; i=++j; // i=
j=41; i=(j++); // i=
j=41; i=j--; // i=
j=41; i= ++j + 42 + j; // i=
j=41; i= j + 42 + j++; // i=
j=41; i= ++j + 42 + j; // i=
ui=142; i=ui; // i=
j=41; i=j + 42 + (j++); // i=
j=41; i=j + 42 + (++j); // i=
j=41; i=(++j) + 42 + j; // i=
j=41; i=--j; // i=
j=41; i=!j; // i=
i=41; i+=41; // i=
j=41; i=j/2; // i=
j=41; i=j%2; // i=
uj=41; ui=uj<<1; // ui=
uj=40; ui=uj>>1; // ui=
j=0xBD; i=~j; // i= 0x
j=0xFF; i=j&&0x42; // i= 0x
j=0xFF; i=j&0x42; // i= 0x
j=0xAA; i=j^0xE8; // i= 0x
j=0xFF; i=j|0x42; // i= 0x
j=42 i=!j; // i=
fd=fi; // i=
//fabs() is a floating point absolute function,
// just the get rid of the negative value
fd=fabs(fj--fi); // i=
i=(fd != 0.00977); // i=
i=(fd == 0.00977); // i=
i>>=0; // i=
i&= !0; // i=
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
