C Operator Questions 4

Hello PrepSter,

If you find any errors in the quiz below kindly comment in the comment section and we will make it our priority to fix it.

Also if you have a better of the solution to the questions, please do comment them below and if we find it better than ours, we will post it in our website.

Question 1

Time: 00:00:00
Assume there are 4 int variables p,q,r,s. Which of the following statement about the ternary operator is true?

p!=q ? : is a acceptable statement where c and d will be given null values.

p!=q ? : is a acceptable statement where c and d will be given null values.

p!=q ? r=100: s=20; is a acceptable statement where depending on the value of p and q, either r is give a value of 100 and s is null or c is null and s is given a value of 10.

p!=q ? r=100: s=20; is a acceptable statement where depending on the value of p and q, either r is give a value of 100 and s is null or c is null and s is given a value of 10.

p!=q ? (r=100,s=15): (r=60, s=20); is a acceptable statement where depending on the value of p and q, either r and s are given a value of 100 and 15 respectively or r and s are given a value of 60 and 20 respectively.

p!=q ? (r=100,s=15): (r=60, s=20); is a acceptable statement where depending on the value of p and q, either r and s are given a value of 100 and 15 respectively or r and s are given a value of 60 and 20 respectively.

All of them are valid ternary statements.

All of them are valid ternary statements.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
What will be the output of the following C program ?

#include<stdio.h> #include<stdlib.h> int top = 0; int ar() { char a[]= {'a','b','c','d','e'}; return a[top++]; } int main() { char b[20]; char ch; int i = 0; while (ch = ar() != 'd') { b[i++] = ch; } b[i] = "\0"; printf("%s",b); return 0; }

abcd

abcd

Three special character values.

Three special character values.

abc

abc

Empty string.

Empty string.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
Select the correct output for the code below.

#include <stdio.h> int main() { int a = 0; a = (a == (a == 1)); printf("%d", a); return 0; }

1

1

-1

-1

0

0

Some garbage value

Some garbage value

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
The correct output for the following program is ?

#include <stdio.h> int main() { int y = 0; int x = (y == 1); printf("%d", x); return 0; }

Incorrect use of operator.Compilation error.

Incorrect use of operator.Compilation error.

1

1

0

0

Some garbage value

Some garbage value

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
What will be the output of the C program below?

#include<stdio.h> int main() { int a = 10,b = 6; a = a^b; b = b^a; printf("%d %d",a,b); return 0; }

6 10

6 10

12 10

12 10

12 12

12 12

10 6

10 6

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
Given a unsigned 16 bit input what is the expected output ?

#include<stdio.h> int main() { unsigned int val; int i; scanf (“%u”, &val); for ( i = 0; i<16; i++) { printf (“%d”, (val << i & 1 << 15 ) ? 1:0); } }

Prints every odd bit and skips the even.

Prints every odd bit and skips the even.

Prints every even bit and skips the odd.

Prints every even bit and skips the odd.

1 is printed.

1 is printed.

Will print the same integer in bits .

Will print the same integer in bits .

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
In C which is the following can not be overloaded?

Structure reference

Structure reference

Bitwise not

Bitwise not

sizeof

sizeof

Indirection

Indirection

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
What is the output of the following code in C language ?

#include<stdio.h> int main() { int y,a,b,i,j,k; y=0; a=1; b=7; i=7; j=1; k=-1; y=a * b < i + j || k; printf("%d",y); return 0; }

0

0

-1

-1

1

1

FALSE

FALSE

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]
Hey ! Follow us on G+