Complete the code to declare an 8-bit unsigned variable.
unsigned char [1] = 255;
We declare an 8-bit unsigned variable named num to hold values from 0 to 255.
Complete the code to assign a negative value to a signed 8-bit variable.
signed char [1] = -128;
The variable temp is declared as signed char to hold negative values down to -128.
Fix the error in the code to correctly add two unsigned 8-bit variables without overflow.
unsigned char a = 200; unsigned char b = 100; unsigned int sum = a [1] b;
Use the + operator to add the two unsigned variables. The sum is stored in a wider type to avoid overflow.
Fill in the blank to correctly check if a signed 8-bit variable is negative.
signed char x = -5; if (x [1] 0) { // x is negative }
Use < to check if x is less than zero.
Fill all three blanks to create a loop that counts down an unsigned 8-bit variable from 10 to 0.
unsigned char i = [1]; while (i [2] 0) { // do something i [3] 1; }
Initialize i to 10, loop while i > 0, and decrement i by 1 each time using -=.