C Programming and Problem Solving
Questions 91 to 100
91.
|
The
associativity of ++ operator is
|
||||||||||
92.
|
Which
operator from the following has the lowest priority?
|
||||||||||
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);
}
|
||||||||||
94.
|
The
function scanf( ) returns
|
||||||||||
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 );
}
|
||||||||||
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 );
}
|
||||||||||
97.
|
What is the output
of the following piece of program?
int value = 11;
while( --value+1 );
printf( “Count down is :
%d”, value);
|
||||||||||
98.
|
What is
the value of the ‘a’ in the expression:
a = ( b=10, b*b );?
|
||||||||||
99.
|
What is the result
of the following code?
void main( ) {
int x = 0;
for(x =1; x<4;
x++ );
printf(“x=%d, ”, x);
}
|
||||||||||
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);
}
|
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.
|
Sorting Searching Code Examples
ReplyDeletethank you.
ReplyDeletec++ tutorial
java tutorial