CIS 15AG
Questions Chapter 3:
Structure of a C Program: Expressions and Statements
1.
Evaluate the following arithmetic expressions. For each result circle the appropriate
type (int, float, double, char).
Expression
Value
Type
a.
11 / 2
int,
float,
double,
char
b.
5 + 2 * 2
int,
float,
double,
char
c.
11 / 2 * 2
int,
float,
double,
char
d.
15 / 5.0
int,
float,
double,
char
e.
11 % 5
int,
float,
double,
char
f.
5 % 11
int,
float,
double,
char
g.
(2 + 2 * 3 + 4 * (5 - 1)) / 2.0
int,
float,
double,
char
2.
What is the output displayed by the following program fragment?
int
a;
int
b;
int
c;
float x;
a = 10;
a = a + 5;
printf( "%3d\n", a );
Answer:
a = 7;
b = 2;
x = (float) a / b;
printf( "%3d %3d %5.2f\n", a, b, x );
Answer:
1