Basic C Programming - Conditional Operator

Basic C Programming - Conditional Operator

12th Grade

10 Qs

quiz-placeholder

Similar activities

Quiz Dasar-Dasar Pemrograman Python

Quiz Dasar-Dasar Pemrograman Python

12th Grade - University

15 Qs

Sosialisasi Pengenalan AEO

Sosialisasi Pengenalan AEO

1st - 12th Grade

10 Qs

JAVA: Level-1

JAVA: Level-1

5th - 12th Grade

15 Qs

ALGORITHMS QUIZ (Post)

ALGORITHMS QUIZ (Post)

1st Grade - University

10 Qs

N5 AIT - Spreadsheets Quiz

N5 AIT - Spreadsheets Quiz

9th - 12th Grade

15 Qs

LPTM OPEN DAY

LPTM OPEN DAY

10th - 12th Grade

10 Qs

Basic C Programming - Order of Precedence

Basic C Programming - Order of Precedence

12th Grade

10 Qs

KATEGORI BLOK

KATEGORI BLOK

12th Grade

10 Qs

Basic C Programming - Conditional Operator

Basic C Programming - Conditional Operator

Assessment

Quiz

Education

12th Grade

Hard

Created by

Hafizul Hasmie

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the syntax of the conditional operator in C?

condition ? expression1 || expression2

condition ? expression1 : expression2

condition ? expression1 expression2

condition ? expression1 : expression2 :

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How does the conditional operator work in C?

The syntax is: condition ? value_if_true : value_if_false;

The syntax is: condition ? value_if_true : value_if_false :

The syntax is: condition ? value_if_true : value_if_false

The syntax is: condition ? value_if_true || value_if_false

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Can the conditional operator be used as a replacement for if-else statements?

Sometimes

Yes

Rarely

No

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the return type of the conditional operator in C?

Always returns an integer

Returns a double

Depends on the type of the second and third operands

Returns a boolean value

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Give an example of using the conditional operator in C.

int x = (a < b) ? a : b;

int x = (a == b) ? a : b;

int x = (a != b) ? a : b;

int x = (a > b) ? a : b;

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What happens if both the true and false expressions in the conditional operator have different data types?

The true expression will be implicitly converted to the data type of the false expression

A compilation error will occur.

The false expression will be implicitly converted to the data type of the true expression

The program will crash at runtime

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Explain the precedence of the conditional operator in C.

Lowest precedence among all C operators, evaluated from left to right.

Has the same precedence as the assignment operator

Evaluated from right to left

Highest precedence among all C operators

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?