C Operators and Expressions 01

C Operators and Expressions 01

University

10 Qs

quiz-placeholder

Similar activities

GODOT ENGINE

GODOT ENGINE

University

10 Qs

Unit 28 - Quiz #1

Unit 28 - Quiz #1

University

15 Qs

Quiz on Basics of C

Quiz on Basics of C

University

10 Qs

PYTHON_CHAPTER 6

PYTHON_CHAPTER 6

University

10 Qs

CHAPTER 5 ONLINE QUIZ

CHAPTER 5 ONLINE QUIZ

University

9 Qs

Sonic-Pi: Duration with Envelopes

Sonic-Pi: Duration with Envelopes

9th Grade - University

14 Qs

Javascript

Javascript

University

12 Qs

STGY PPS QUIZ  TEST

STGY PPS QUIZ TEST

University

15 Qs

C Operators and Expressions 01

C Operators and Expressions 01

Assessment

Quiz

Computers

University

Hard

Created by

Sumit Mittu

Used 4+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 4 pts

What the output of the following code?

float x = 5*2+15/2+25%3 ;

printf("%g", x);

18

18.0

18.5

Garbage value due to %g

Answer explanation

Expression 5*2+15/2+25%3 evaluates as:

5*2+15/2+25%3

* 10 + 15/2 + 25%3

/ 10 + 7 + 25%3

% 10 + 7 + 1

  • + 17 + 1

  • + 18

Store 18.0 into x (a float variable)

The %g format specifier removes trailing 0s after decimal point and prints 18 for x

2.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

In C programming language, which of the following type of operators have the highest precedence

Relational operators

Shift operators

Logical operators

Arithmetic operators

Answer explanation

Among the given options: Arithmetic Operators have highest priority followed by Shift Operators then Relational Operators and then Logical Operators.

3.

MULTIPLE CHOICE QUESTION

30 sec • 4 pts

What is the output of the following code:

int x=3, y=4;

int z = ++x * y++;

printf("%d %d %d", x, y, z);

4 3 12

4 4 16

4 5 16

4 5 20

Answer explanation

int x=3, y=4;

int z = ++x * y++;

Solves as

z = (increment x and use x) + (use y and then increment y)

z = 4 * 4 (alongside incrementing x to 4 and y to 5)

z = 16

Hence x y z values are printed as 4 5 16 respectively

4.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

The modulus operator (%) can be used with floating point values.

True

False

Answer explanation

The modulus operator can be used only with integer operands

5.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

!= is one of the ______ operators.

Relational

Logical

Assignment

Conditional

6.

MULTIPLE CHOICE QUESTION

10 sec • 1 pt

Which of the following is not a Bitwise operator?

&

|

<<

&&

Answer explanation

&& (Logical AND) is a Logical operator

7.

MULTIPLE CHOICE QUESTION

20 sec • 2 pts

What is the output of the following code segment assuming GCC compiler:

char c = 65;

printf("%d", sizeof(c));

1

2

4

Undefined.

Size varies from on compiler to compiler

Answer explanation

c is a char type variable.

char variables occupy 1 byte of memory. hence sizeof(c) will return sizeof(char) i.e. 1

Create a free account and access millions of resources

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?