Name:

cs202 login:

Quiz 2 - C keywords and data types


1) Data types

1.1) Give a formula for the largest integer that can be stored in an 8 bit unsigned integer?

1.2) How many bytes does an int take with gcc on the CS server

1.3) Give correct C code to declare a floating point variable named x



2) Keywords

What do the following keywords in C mean / what are they used for?

2.1) for

2.2) while

2.3) if

2.4) #include

2.5) break

2.6) continue

2.7) sizeof

2.8) switch

2.9) char

2.10) double

2.11) case

2.12) default

2.13) const

2.14) unsigned



3) Operators

What is the result of the following operations?

3.1) 12 & 14

3.2) 7 && 4

3.3) 1 + 2 * 3

3.4) 5 / 2

3.5) 1 << 3

3.6) 1 < 2 && 2 < 1

3.7) 1 < 2 || 2 < 1

3.8) 5 % 3

3.9) 4 <= 4.0

3.10) x = 3

3.11) 12 ^ 14

3.12) 'b' - 'a'



4) Main

Write down a complete C program that BLANK
- Asks the user for 3 integers and prints the smallest
- Asks the user for their first and last name and prints them together
- Asks the user for a floating point number and tells them if they "pass"



5) Functions

Write code for a C function that BLANK
- Any of the above from main
- Anything that requires some combination of a loop or two and if tests