Showing posts with label operators mcq questions. Show all posts
Showing posts with label operators mcq questions. Show all posts

Wednesday, 8 November 2017

Operators Questions in C2


6.

Find the output of the following program.

#include void main() 

int y=10;
 if(y++>9 && y++!=10 && y++>11) 
printf("%d", y); 
else 
printf("%d", y); 
}

A. 11
B. 12
C. 13
D. 14
E. Compilation error

Answer: C

---------------------------------------------------------------------------------------------------

7.

Determine output of the following program code.

#include 
void main()
 {
 int a, b=7; a = b<4 :="" b="">4 ? 7>>1 : a; 
printf("%d %d", a, b); 
}

A. 3 7
B. 7 3
C. 8 3
D. 3 8
E. None

Answer: D

------------------------------------------------------------------------------------------------
8.

Choose the correct output for the following program.


#include 
void main() 
{
 int a=10, b=11, c=13, d; 
d = (a=c, b+=a, c=a+b+c); 
printf("%d %d %d %d", d, a, b, c); 
}


A. 50, 13, 11, 13
B. 50, 13, 24, 50
C. 13, 10, 24, 50
D. 50, 13, 24, 13
E. 13, 13, 24, 13


Answer : B


------------------------------------------------------------------------------------------------

9. 

What will be output of the following program?

#include
int main(){
    int a;
    a=015 + 0x71 +5;
    printf("%d",a);
    return 0;
}


Output: 

Turbo C++ 3.0: 131


Turbo C ++4.5: 131


Linux GCC: 131


Visual C++: 131

---------------------------------------------

10.

What is the output of this C code?

int main() 
{
 int i = -5; 
int k = i %4; 
printf("%d\n", k); 
}

A. Compile time error
B. -1
C.  1
D. None

Answer: B

----------------------------------------------------------------
First                  Previous  Next                     Last
----------------------------------------------------------------

More Imp Topics










Operators Questions in C1



An operator is a symbol that tells the compiler to perform specific mathematical or logical functions. C language is rich in built-in operators and provides the following types of operators −
  • Arithmetic Operators
  • Relational Operators
  • Logical Operators
  • Bitwise Operators
  • Assignment Operators
  • Misc Operators
--------------------------------------------------------------

1. 
Which of the following operator takes only integer operands?

A. +
B. *
C. /
D. %
E. None of these

Answer: D

--------------------------------------------------------

2.
In an expression involving || operator, evaluation 

I. Will be stopped if one of its components evaluates to false 
II. Will be stopped if one of its components evaluates to true
III. Takes place from right to left
IV. Takes place from left to right

A. I and III
B. I and II
C. II and III
D. II and IV
E. III and IV

Answer: D
------------------------------------------------------------

3. 

Which operator from the following has the lowest priority?

A. Assignment operator
B. Division operator
C. Comma operator
D. Conditional operator
E. Unary-operator

Answer: C
------------------------------------------------------------

4. 

What will be the output when following code is executed?

void main() 
{ int a=10, b; 
b = a++ + ++a; 
printf("%d %d %d %d", b, a++, a, ++a);
}

A. 12 10 11 13
B. 22 12 12 13
C. 22 11 11 11
D. 22 14 12 13
E. 22 13 13 13

Answer: E
-------------------------------------------------------------

5.

Identify the correct output of the following code:

void main() 
int w=10, x=5, y=3, z=3; 
if( (w < x ) && (y=z++) ) 
printf("%d %d %d %d", w, x, y, z); 
else 
printf("%d %d %d %d", w, x, y, z); 
}

A. 10 5 4 4
B. 10 5 3 3
C. 10 5 4 3
D. 10 5 3 4
E. 10 5 5 5

Answer: B
----------------------------------------------------------------
First                      Next                               Last
----------------------------------------------------------------

More Imp Topics






















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...