C Programming and Problem Solving
Questions 191 to 200
191.
|
Identify
the wrong statement from the
following code block:
int a;
float b; char c;
|
||||||||||
What should
be the initial values for a, b, c, if 2 has to be printed with the following
code?
void
main(){
int a, b, c;
printf(
“%d”, ( c>=b>=a ? 1 : 2 ));
}
|
|||||||||||
If
suppose a variable ‘a’ is initialized as int a=0xff, then what will be output
for the below code?
( a
<< 4 >> 12 )? printf(“Humaira”) : printf( “Iram” );
|
|||||||||||
What is
the value of ‘a’, if the expression is executed as a = ( x=10, x*x );?
|
|||||||||||
How many
times the ‘for’ loop in the following code will be executed on Turbo C
compiler?
void main(){
int
i=0;
for(; ++i; )
|
|||||||||||
Consider
the following code:
unsigned
char c;
for( c=0;
c!=256; c+2)
printf(“%d”, c);
How
many times the loop will be executed?
|
|||||||||||
What is
the output of the following code?
void main() {
int
i=0;
switch(
i ){
case
0: i++;
case
1: i+++2;
case
2: ++i;
}print(
“%d”, i++ );
}
|
|||||||||||
Identify
the correct statement from the
following statements.
|
|||||||||||
How is
a variable accessed from another file?
|
|||||||||||
The
address of the starting element of an array is
|
Answers
191.
|
Answer : (a)
Reason : For
character variable ‘c’ the ‘&’ is missing in scanf() function.
|
Answer : (e)
Reason : These
are the possible values with which the condition becomes false and 2 will be
printed. Also the execution for c >= b >= a is left toright.
|
|
Answer : (d)
Reason : The
execution of a << 4 >> 12 is left to right. First a becomes 255
and then becomes 0, and hence the outcome of the expression is false. So
“Iram” only will be printed.
|
|
Answer : (e)
Reason : The
outcome of comma separated expression in round brackets is always the right
most expression, hence it is 10*10 which is 100.
|
|
Answer : (c)
Reason : Because
i will be incremented up to the maximum value an integer can have, then it
becomes -1 and in next iteration becomes 0 which caises the for loop to be
terminated.
|
|
Answer : (d)
Reason : What
so for, the value of c is not incremented here at all c+2 is not for
incrementing c by 2. Hence always the condition in for loop remains true
always.
|
|
Answer : (c)
Reason : First
i is incremented by one as ( i++ in first case), then again incremented in
second case and one more time in next case.
|
|
Answer : (a)
Reason : Others
according to the syntax rules of C are wrong and invalid.
|
|
Answer : (b)
Reason : If
a global variable in referenced via extern in a new file then only we can
access that variable in the file. Other variables can never be accessed.
|
|
Answer : (c)
Reason : Because
the address of the array is same as the address of the first element of the
array.
|
thank you.
ReplyDeletec++ tutorial
java tutorial