notes/education/software development/ECE1400/Chapter 7 Exercises.md
2024-10-01 21:01:24 -06:00

728 B

  1. Which of the following aren not legal types in C?

a. short unsigned int b. short float c. long double d. unsigned long

Answer: b. short float

  1. If c is a variable of type char, which of the following statements is illegal?
char c;
// A:
i += c; // i has type int
// B:
c = 2 * c - 1;
// C:
putchar(c);
// D:
printf(c);

Answer: D is illegal because printf operates on strings, not chars.

  1. For each of the following items of data, specify which one of the types char, short, int, or longis the smallest one guaranteed to be large enough to store the item.

Answer: A. Days in a month: char B. Days in a year: short C. Minutes in a day: short D. Seconds in a day: long