Operator
Question 1 
Consider the following C++ program
Assuming the required header files are already included, the above program:
Assuming the required header files are already included, the above program:
results in a compilation error  
print 123  
print 111  
print 322 
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.
→ 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);
}
#include <stdio.h>
int main (void)
{
int shifty;
shifty = 0570;
shifty = shifty >>4;
shifty = shifty <<6;
printf("the value of shifty is %o",shifty);
}
the value of shifty is 1500  
the value of shifty is 4300  
the value of shifty is 5700  
the value of shifty is 2700 
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}
(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
y=y+1;
z=x+y;
x=x+1
z = x + y + 2;  
z = (x++) + (++y);  
z = (x++) + (y++);  
z = (x++) + (++y) + 1; 
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++ postincrement , so it will perform action which is addition and later the value of “x” is incremented .
++y preincrement , 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)
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++ postincrement , so it will perform action which is addition and later the value of “x” is incremented .
++y preincrement , 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%21
z=x+y*z/4%21
*/%+=  
=*/%+  
/*%+=  
*%/+= 
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;
n=5;
x=n++;
y=x;
5,4  
6,5  
6,6  
5,5 
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.
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++;
assigns 3 to a[5]  
assigns 4 to a[5]  
assigns 4 to a[4]  
what is assigned is compiler dependent 
Question 6 Explanation:
Given statement consists of three operators which are preincrement , postincrement and equal to operator. According to operator precedence and associativity, the order of operators evaluation is postincrement,preincrement 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
Unary operator  
ternary operator  
binary Operator  
Not an operator 
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.
● 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):(xy);
What will be the value of x after the code is executed?
int x=22,y=15;
x=(x>y)?(x+y):(xy);
What will be the value of x after the code is executed?
22  
37  
7  
37 and 7 
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?
Relational operators
 
Conditional operators
 
Logical AND and OR operators
 
Arithmetic multiply and divide operators

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?
48  
45  
46  
49 
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 preincremented 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)
→ The initial value of “x” is 10 and it is preincremented 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.