.obsidian
.stfolder
IT
education
computer engineering
ECE1400
(not) Chapter 11 Exercises.md
C.md
Chapter 11 Exercises.md
Chapter 12 Exercises.md
Chapter 13 Exercises.md
Chapter 14 Exercises.md
Chapter 15 Exercises.md
Chapter 16 Exercises.md
Chapter 17 Exercises.md
Chapter 2 Exercises.md
Chapter 3 Exercises.md
Chapter 4 Exercises.md
Chapter 5 Exercises.md
Chapter 6 Exercises.md
Chapter 7 Exercises.md
Chapter 8 Exercises.md
Chapter 9 Exercises.md
Flowcharts and Pseudocode.md
ECE1410
ECE2700
english
Ohm's Law.md
math
nutrition
statistics
notes
personal
software
..gitignore.un~
.gitignore
.gitignore~
48 lines
1.2 KiB
Markdown
48 lines
1.2 KiB
Markdown
> 3. 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`
|
|
|
|
> 4. If `c` is a variable of type `char`, which of the following statements is illegal?
|
|
|
|
```c
|
|
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 `char`s.
|
|
|
|
> 6. For each of the following items of data, specify which one of the types `char`, `short`, `int`, or `long`is 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`
|
|
|
|
> 10. Suppose that `i` is a variable of type `int`, `j` is a variable of type `float`, and `k` is a variable of type `unsigned int`. What is the type of the expression `i + (int) j * k`?
|
|
|
|
Answer:
|
|
`unsigned int`
|
|
|
|
> 15. Use `typedef` to create types named `Int8`, `Int16`, and `Int32`. Define the types so that they represent 8 bit, 16 bit, and 32 bit integers on your machine.
|
|
|
|
Answer:
|
|
```C
|
|
typedef char Int8;
|
|
typedef short Int16;
|
|
typedef long Int32;
|
|
``` |