CS 202, fall 2019
Quiz 2

Grading - each part in #s 1-3 is worth the same amount, 1 point, graded all or nothing.  #4 is worth 4 points.  There are 44 points altogether, and this will be rescaled in blackboard to be worth 10 points.

Please fill in the following.

0) Name:



1) Data types
1.1) # bytes for a float with gcc on cs: 4

1.2) Formula for smallest and largest for a k-bit signed integer: -2^(k-1) to (2^(k-1))-1

1.3) FALSE in C is really: 0

1.4) TRUE in C is really:  1 (non-zero)

1.5) # bytes for a long int with gcc on cs: 8

1.6) # bytes for a double with gcc on cs: 8

1.7) Formula for largest integer that can be stored with a k-bit unsigned integer: 2^k - 1

1.8) # bytes for a char with gcc on cs: 1

1.9) # bytes for an int with gcc on cs: 4



2) Keywords
What is the keyword in C for each of the following?

2.1) declare a floating point number: float, double

2.2) stop the innermost loop: break

2.3) declare a constant variable: const

2.4) conditional execution (one word): if (while is not the best answer)

2.5) goes with conditional execution sometimes (one word): else

2.6) declare a character: char

2.7) to include a header file: #include (include I guess okay) 

2.8) how many bytes does a data type take: sizeof

2.9) loop with continuing condition only: while

2.10) declare an unsigned variable: unsigned

2.11) loop with init, condition, increment: for

2.12) to go back to the top of the loop, check the condition again: continue

2.13) short-hand for many if/else if statements with integer/char values (three keywords that are used): 
switch, case, default, break


3) Operators
What is the result of the following operations?

3.1) 32 >> 2 : 8

3.2) 13 % 10 : 3

3.3) 13 == 9 : 0 (do not accept FALSE, false)

3.4) 13 | 9 : 13 (accept 1101b)

3.5) 3 + 2 * 1 : 5

3.6) 13 / 10 : 1

3.7) 15.0 / 10 : 1.5 

3.8) 13 & 9 : 9

3.9) 13 <= 9 : 0

3.10) 13 > 9 : 1

3.11) 13 || 9 : 1

3.12) 13 >= 9 : 1

3.13) 13 != 9 : 1

3.14) 1 << 4 : 10000b or 16

3.15) 'C' - 'A' : 2

3.16) 13 && 9 : 1

3.17) 13 ^ 9 : 4 or 100b

3.18) 13 < 9 : 0

4) Main (4 points)
Write down a complete C program that asks the user for 3 integers and prints the smallest

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

  printf("3 int's please: ");
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  if (a <= b && a <= c) printf("%d\n", a);
  else if (b <= a && b <= c) printf("%d\n", b);
  else printf("%d\n", c);

  return 0;
}