What is the value of x after the following code is executed?
int x = (5 > 3) ? 10 : 20;
Quiz - 8 on conditional/ternary operator
Quiz
•
others
•
•
Medium
Michael Kona
Used 3+ times
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the value of x after the following code is executed?
int x = (5 > 3) ? 10 : 20;
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the value of y after the following code is executed?
int y = (5 < 3) ? 10 : 20;
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the following code print?
int a = 1, b = 2;
printf("%d", (a > b) ? a : b);
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the value of result after the following code is executed?
int x = 4;
int result = (x % 2 == 0) ? x * 2 : x * 3;
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the following code print?
int a = 3, b = 5;
printf("%d", (a == b) ? 100 : 200);
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the value of z after the following code is executed?
int x = 10, y = 20;
int z = (x > y) ? x : y;
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the following code print?
int a = 7;
printf("%s", (a % 2 == 0) ? "even" : "odd");
17 questions
Lesson six - Sensing
Quiz
•
KG - University
13 questions
Parcial 1-Laboratorio II-5to BACO-I Unidad Forma A
Quiz
•
KG - University
11 questions
Java Refresher
Quiz
•
KG - University
15 questions
Unit 2 Test B
Quiz
•
9th Grade - University
15 questions
Parcial I - I Serie- Programación I - 4to BACO - I Unidad
Quiz
•
KG - University
11 questions
Byzantine Empire Review 2025
Quiz
•
6th - 8th Grade
10 questions
Ch. 1 Lesson 2: The Byzantine Empire Quiz
Quiz
•
7th Grade
15 questions
Quiz - 5 on Increment and Decrement Operators
Quiz
•
KG - University
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade