C - Control Flow Constructions
C - Control Flow Constructions
41. main ( )
{
int i = 0;
for ( ; ++ i ;)
printf ( "%d", i );
}
How many times the for loop will be executed ?
{
int i = 0;
for ( ; ++ i ;)
printf ( "%d", i );
}
How many times the for loop will be executed ?
- 0
- infinite
- 32767
- The maximum integer value that can be represented in the machine.
42. main ( )
{
unsigned int i =10 ;
while ( i - - > = 0) ;
}
How many times the loop will be executed ?
{
unsigned int i =10 ;
while ( i - - > = 0) ;
}
How many times the loop will be executed ?
- 10
- zero time
- one time
- none
43. main ( )
{
int score = 4 ;
switch (score)
{
default :
;
case 3 :
score +=5;
if ( score == 8)
{
score ++;
if (score == 9) break ;
score *= 2;
}
score -=4;
break;
case 8:
score +=5;
break ;
}
printf ("score = %d\n", score);
}
What will be the output of the above code ?
{
int score = 4 ;
switch (score)
{
default :
;
case 3 :
score +=5;
if ( score == 8)
{
score ++;
if (score == 9) break ;
score *= 2;
}
score -=4;
break;
case 8:
score +=5;
break ;
}
printf ("score = %d\n", score);
}
What will be the output of the above code ?
- SCORE = 5
- SCORE = 4
- SCORE = 9
- SCORE = 10
44. main ( )
{
int score = 4;
switch (score)
{
default:
;
case 3 :
score += 5;
if ( score = = 8)
{
score++;
if ( score = = 9) break ;
score *= 2;
}
score -=4;
break;
case 8:
score +=5;
break;
}
printf ( "SCORE = %d\n", score);
}
What will be the output of the above code ?
{
int score = 4;
switch (score)
{
default:
;
case 3 :
score += 5;
if ( score = = 8)
{
score++;
if ( score = = 9) break ;
score *= 2;
}
score -=4;
break;
case 8:
score +=5;
break;
}
printf ( "SCORE = %d\n", score);
}
What will be the output of the above code ?
- SCORE = 5
- SCORE = 4
- SCORE = 9
- SCORE = 10
45. switch (s)
{
case 1 : printf ("Balan")
case 2 :
case 3 : printf ("Elango")
case 4 : printf ("Thiruvalluvan")
default : printf ("Kamban")
}
To print only Kamban, what will be the value of s ?
{
case 1 : printf ("Balan")
case 2 :
case 3 : printf ("Elango")
case 4 : printf ("Thiruvalluvan")
default : printf ("Kamban")
}
To print only Kamban, what will be the value of s ?
- 2
- 1 or 3 or 4
- any int value other than 1, 2, 3 and 4
- 4
46. main ( )
{
int a =-4, r, num = 1;
r = a% -3;
r = ( r ? 0 : num * num) ;
printf ("%d". r);
}
What will be the output of the program ?
{
int a =-4, r, num = 1;
r = a% -3;
r = ( r ? 0 : num * num) ;
printf ("%d". r);
}
What will be the output of the program ?
- 0
- 1
- -ve is not allowed in the mod operands.
- none
47. main ( )
{
int a =-4, r, num = 1;
r = a% -3;
r = ( r ? 0 : num * num) ;
printf ("%d". r);
}
What will be the output of the program ?
{
int a =-4, r, num = 1;
r = a% -3;
r = ( r ? 0 : num * num) ;
printf ("%d". r);
}
What will be the output of the program ?
- 0
- 1
- -ve is not allowed in the mod operands.
- none
48. What is the value of int variable result if x = 50, y = 75 and z = 100?
result = ( x + 50 ? y >= 75 ? z > 100 ? 1 : 2 : 3 : 4 ) ;
result = ( x + 50 ? y >= 75 ? z > 100 ? 1 : 2 : 3 : 4 ) ;
- 1
- 2
- 3
- 4
49. Omitting the break statement from a particular case
- leads to a syntax error
- causes execution to terminate after that case
- causes execution to continue all subsequent cases
- causes execution to branch to the statement after the switch statement
50. int i ;
i=2;
i++;
if (i = 4)
{
printf "i=4");
}
else
{
printf("i=3");
}
what is the out of the program ?
i=2;
i++;
if (i = 4)
{
printf "i=4");
}
else
{
printf("i=3");
}
what is the out of the program ?
- i = 4
- i = 3
- unpredictable
- none