Professional Documents
Culture Documents
Comprog11 Oct. 25
Comprog11 Oct. 25
CLASS AGENDA
• Attendance
• Midterm Departmental Exam
Wednesday, October 26, 2022 (face-to-face)
Time: 8:30 AM – 10:00 AM
Room: A2401
C Expressions
Selection Structures
3
1) Which of the following is the
complement of less than (<)?
a) >
b) >=
c) < =
1) Which of the following is the
complement of less than (<)?
a) >
b) >=
c) < =
Comparative
Operator
Complements
2) If a variable, x, contains the
value 3, the value of the
expression x-- is 2?
a) True
b) False
2) If a variable, x, contains the
value 3, the value of the
expression x-- is 2?
a) True
b) False
3) Given the following code, what
is printed?
9
3) Given the following code, what
is printed?
Answer: 11 10
10
4) Given: x = 15 y = 10 z=5
11
4) Given: x = 15 y = 10 z=5
Answer: -17
12
5) Given: x = 15 y = 10 z = 5
13
5) Given: x = 15 y = 10 z = 5
Answer: 100
14
6) What is the output of the code below?
int a=1;
if (a > 0)
printf("True");
if (a == 2)
printf("False")
else
printf("Invalid");
15
6) What is the output of the code below?
int a=1;
if (a > 0)
printf("True");
if (a == 2) Answer: error
printf("False") ;
else
printf("Invalid");
16
7) What is the output of the code below?
int a=1;
if (a > 0) {
printf("True");
}
else {
printf("False");
}
printf("Invalid"); 17
7) What is the output of the code below?
int a=1;
if (a > 0) {
printf("True");
} Answer:
else { TrueInvalid
printf("False");
}
printf("Invalid"); 18
8) What is the output of the code below?
int x=3;
switch(x)
case 1: printf("%d", x);
case 2: printf("%d", --x);
default: printf("%d", x++);
19
8) What is the output of the code below?
int x=3;
switch(x)
{
case 1: printf("%d", x);
case 2: printf("%d", --x);
default: printf("%d", x++);
}
Answer: error
20
9) What is the output of the code below?
char initial='a';
switch(initial)
{
case 'A':
case 'a':
printf("True");
default:
printf("False");
} 21
9) What is the output of the code below?
char initial='a';
switch(initial)
{ Answer:
case 'A':
case 'a':
TrueFalse
printf("True");
default:
printf("False");
} 22
10) --a is a postfix
expression.
A) True
B) False
23
10) --a is a postfix
expression.
A) True
B) False
24
Program Tracing
(by pair)
25
Practice
(by pair)
Midterm Departmental
Exam – Answer Sheet
26
Good luck,
students!
27