Operator

Question 1
Consider the following C++ program

Assuming the required header files are already included, the above program:
A
results in a compilation error
B
print 123
C
print 111
D
print 322
       Programming       Operator       ISRO-2018       Video-Explanation
Question 1 Explanation: 
Solution: A but official key given solution D
→ It gives compilation error because declaration of “intc” is wrong.
→ q+=b(a(q)) and r+=a(c(r)) will result compilation error.
Question 2
Write the output of the following C program
#include <stdio.h>
int main (void)
{
int shifty;
shifty = 0570;
shifty = shifty >>4;
shifty = shifty <<6;
printf("the value of shifty is %o",shifty);
}
A
the value of shifty is 1500
B
the value of shifty is 4300
C
the value of shifty is 5700
D
the value of shifty is 2700
       Programming-for-Output-Problems       Operator       ISRO CS 2014       Video-Explanation
Question 2 Explanation: 
Given, shifty = 0570; // number starts with 0 means that number is octal number.
(0570)8 = (000 101 111 000)2 (Converting octal number into binary number)
shifty = shifty >>4 ( >> right shift operator where we need to shift the 4 bits towards right side means discard last four bits )
After right shifting 4 bits the shifty consists of the following digits
shifty = (000 000 010 111) 2
shifty = shifty <<6( << left shift operator where we need to shift the 6 bits towards left side means add si bits to the end of the binary number. So the binary number becomes as follows shifty = (010 111 000 000) 2
= (2700) 8
Question 3
The following three ‘C’ language statements is equivalent to which single statement?
y=y+1;
z=x+y;
x=x+1
A
z = x + y + 2;
B
z = (x++) + (++y);
C
z = (x++) + (y++);
D
z = (x++) + (++y) + 1;
       Programming-for-Output-Problems       Operator       ISRO CS 2014       Video-Explanation
Question 3 Explanation: 
From the below statements
y=y+1;
z=x+y;
x=x+1
First statement: “y” value is incremented by 1
Second statement : that incremented value is added to x and stored into “z”
Third statement : “y” value is incremented by 1
z = (x++) + (++y);
X++ post-increment , so it will perform action which is addition and later the value of “x” is incremented .
++y pre-increment , here first value “y” is incremented and updated value is added to value x.
Finally the result will store into z.
The sequence of operations you can find from the below statements
z=x+y; //z = x + (++y)
x=x+1 //z = (x++) + (++y)
Question 4
Which of the following is the correct order of evaluation for the below expression?
z=x+y*z/4%2-1
A
*/%+-=
B
=*/%+-
C
/*%-+=
D
*%/-+=
       Programming       Operator       Nielit Scientist-B IT 4-12-2016
Question 4 Explanation: 
Here, *,/,% are having same priority. So, it executes follows first come first serve or left to write. +,- are having same priority. So, it executes follows first come first serve or left to write. = having least priority. It evaluates right to left.
Question 5
What will be the value of x and y after execution of the following statement (C language)
n=5;
x=n++;
y=-x;
A
5,-4
B
6,-5
C
6,-6
D
5,-5
       Programming       Operator       Nielit Scientist-C 2016 march
Question 5 Explanation: 
Given statements are n=5, x=n++ and y=-x.
N++ is post increment statement, so first “n” will store into variable into “x” and later “n” value is incremented.
X value becomes 5 and y value become -5.
Question 6
If n has 3, then the statement a[++n]=n++;
A
assigns 3 to a[5]
B
assigns 4 to a[5]
C
assigns 4 to a[4]
D
what is assigned is compiler dependent
       Programming-for-Output-Problems       Operator       ISRO CS 2015       Video-Explanation
Question 6 Explanation: 
Given statement consists of three operators which are pre-increment , post-increment and equal to operator. According to operator precedence and associativity, the order of operators evaluation is post-increment,pre-increment and finally equal to operator. But one variable value is modifying multiple times in the same expression means that behaviour is undefined behaviour which is compiler dependent.
Question 7
cross product is a
A
Unary operator
B
ternary operator
C
binary Operator
D
Not an operator
       Programming       Operator       Nielit Scientist-B IT 22-07-2017
Question 7 Explanation: 
● The cross product of two tables A x B builds a huge virtual table by pairing every row of A with every row of B.
● This operator requires two tables so it binary operator.
Question 8
Consider the following code segment:
int x=22,y=15;
x=(x>y)?(x+y):(x-y);
What will be the value of x after the code is executed?
A
22
B
37
C
7
D
37 and 7
       Programming       Operator       KVS 22-12-2018 Part-B
Question 8 Explanation: 
The condition 22>15 is true so it will execute 22+15 which is 37
Question 9

Which of the following ‘C’ language operators has the right to left associativity?

A
Relational operators
B
Conditional operators
C
Logical AND and OR operators
D
Arithmetic multiply and divide operators
       Programming       Operator       JT(IT) 2018 PART-B Computer Science
Question 9 Explanation: 
Logical AND and OR operators are having right to left associativity.
Question 10
What will be the value of C, in C=x++ + ++x + ++x + x, if x=10?
A
48
B
45
C
46
D
49
       Programming       Operator       KVS DEC-2013
Question 10 Explanation: 
→ Incrementing the same variable multiple times with in the same expression is abnormal behaviour. Multiple compiler gives different outputs.
→ The initial value of “x” is 10 and it is pre-incremented two times and later addition will be performed from left to right.
→ While performing the addition the variable “x” value is 12 and we adding four “x” variables so answer is 48 (output is based upon the Gcc compiler)
There are 10 questions to complete.

Access quiz wise question and answers by becoming as a solutions adda PRO SUBSCRIBER with Ad-Free content

Register Now

If you have registered and made your payment please contact solutionsadda.in@gmail.com to get access