ECE 473 - Embedded Systems

Sample C Programming Questions

  1. Variables (Types, Sizes, Global vs. Local, Pointers)
    1. Declare an 8-, 16- or 32-bit unsigned variable called var1
    2. What are the ranges for the variables in a. (e.g. 8-bit range is 0 - 255)
    3. Declare an 8-, 16- or 32-bit signed variable called var1
    4. What are the ranges for the variables in c. (e.g. 8-bit range is -128 to 127)
    5. Show how to declare a global variable
    6. Show how to declare a local variable
    7. Define a pointer to an 8-bit unsigned value
    8. Assign the 8-bit value 0xAB to the address pointed to by the pointer in g.

  2. Arrays and Strings
    1. Define an array to hold a 100-character string
    2. Assign the value "Hello World" (without the quote marks) to the array defined in a.

  3. Mathematical and Logical operations
    1. Show the logical AND and OR operations on the variables VAR1 and VAR2
    2. Show the bitwise AND and OR operations on the variables VAR1 and VAR2

  4. Flow of Control (if-then-else, while loops, for loops, etc.)
    1. Write a for loop (skeleton only) that will iterate 100 times
    2. Write a while loop (skeleton only) that will continue as long as the 8-bit variable A is less than 250
    3. Write an if-then-else structure that will determine if a value is between 0 and 5, 6 and 10, 11 and 15 or 16 and 20 (four cases)

  5. Functions and Parameter Passing
    1. Call the function "function1" where function1 uses the variables var1, var2 and var3.  var1 and var2 should be "call by value" (send the values of var1 and var2) and var3 should be "call by reference" (address of var3).
    2. Give the function prototype for function1 described in a.