C Programming and Problem Solving Questions and Answers 91 to 100

C Programming and Problem Solving

Questions 91 to 100



91.
The associativity  of  ++ operator is
(a)
Left to right
(b)
Right to left
(c)
(a) for arithmetic expression and (b) for pointer expression
(d)
(a) for pointer expression and (b) for arithmetic expression
(e)
Depends upon the expression.
92.
Which operator from the following has the lowest priority?
(a)
Assignment operator
(b)
Division operator
(c)
Comma operator
(d)
Conditional operator
(e)
Unary-operator.
93.
What is the output of the following piece of code in Turbo C?
       void main( ) {
            int a=20, b=35;
            a = b++ + a++;
            b = ++b + ++a;
            printf( “ %d, %d”, a, b);  
       }
(a)
57, 94
(b)
56, 94
(c)
58, 94
(d)
57, 93
(e)
55, 55.
94.
The function scanf( ) returns
(a)
The actual values read for each argument
(b)
0
(c)
1
(d)
The number of successful read input values
(e)
ASCII value of the input read.
95.
What will be the output of following program if the inputs are 2, 3 respectively?
       void  main( )   {
            int  x,  y;
            printf( “\n Enter two values : ” );
            scanf( “%d%d”, x, y);
            printf( “%d+%d=%d”, x, y, x+y );
       }
(a)
2+3=5
(b)
Syntax error
(c)
x + y = 5
(d)
x + y = x + y
(e)
Will generate runtime error ( core dump ).
96.
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   3   3
(b)
10   5   4   4
(c)
10   5   3   4
(d)
10   5   4   3
(e)
10   5   5   5.
97.
What is the output of the following piece of program?
            int   value = 11;
            while( --value+1 );
                     printf( “Count down is : %d”, value);
(a)
Count down is : 0
(b)
Count down is : -1
(c)
Count down is : 1
(d)
Syntax error
(e)
Run time error.
98.
What is the value of the ‘a’ in the expression:  a = ( b=10, b*b );?
(a)
Syntax error
(b)
Run time error
(c)
100
(d)
10
(e)
0.
99.
What is the result of the following code?
       void main( )  {
            int   x = 0;
            for(x =1;  x<4;  x++ );
              printf(“x=%d, ”, x);
       }
(a)
x = 0,
(b)
x = 1,
(c)
x = 3,
(d)
x = 4,
(e)
x = 1, x = 2, x = 3.
100.
What will be printed if the following code is executed?
       void main( )   {
            int  x = 0;
            for(  ;  ; )  {
              if( x++ == 4 ) break;
                     continue;
            }
            printf( “x = %d”, x);
       }
(a)
x = 0
(b)
x = 5
(c)
x = 4
(d)
x = 1
(e)
Error, because break and continue can not appear in one for loop.

Answers


91.
Answer : (b)
Reason : According to the Syntactical rules and semantics operator ++ always has got right to left associativity.
92.
Answer : (c)
Reason : As the other operators are having the highest priority over the comma operator.
93.
Answer : (a)
Reason : Because of the postfix and prefix operations.
94.
Answer : (d)
Reason : According to the prototype, the return type of scanf( ) function is int, that is the number of successful read input values.
95.
Answer : (e)
Reason : As in scanf( ) statement the address operator( & ) of variables x, y is missed.
96.
Answer : (a)
Reason : Because as the first condition ( w<x) is false and the logical operator && is used, the entire relation becomes false and the second part ( y=z++) is not executed.
97.
Answer : (b)
Reason : As the while loop decrements the value every time by one and does nothing and terminates when value reaches -1.
98.
Answer : (c)
Reason : In a comma separated expression enclosed with in the parenthesis the outcome is the rightmost part of the expression and hence here it is b*b.
99.
Answer : (d)
Reason : Because there is a semi colon at the end of for loop and hence it does nothing. When loop is terminated the value of ‘x’ is printed.
100.
Answer : (b)
Reason : Because of the postfix operation on x.



<< Prev 1...  2...  3...  4...  5...  6...  7...  8...  9...  10...  11... 12...  13...  14...  15...  16...  17...  18...  19...  20...  21...  22...  23...  24...  25...  26...  27...  28...  29...  30...  31...  32...  33...  34...  35...  36...  Next >>


2 comments :