How many “*” are printed when the following C code is executed
int i,j;
for (i =1; i<=5;i++)
for(j=i;j<=5;j++)
printf("*");
15
Evaluate the C expression
!(1 && !(0 || 1))
what is the result?
True
What will be the output for this code:
int x=1;
if(--x)
printf("Hi");
else
printf("Bye");
Bye
what is the output from the following C code:
int i = 0;
switch(i)
{
case'0': printf("Hello");
break;
case'1': printf("C");
break;
default: printf("World");
}
World
How many times is the body statement in a do-while loop guaranteed to execute?
1
Float expressions are allowed in switch cases.
false
A do-while loop is useful when we want that the statements within the loop must be executed
At Least Once
In a switch statement, what is required to avoid falling through from one case to the next?
break
what are the output from the following C code: int i = 3;
while(i--)
{
int i = 100;
i--;
printf("%d ", i);
}
99 99 99
What is the output from the following C code:
int x=1;
if(x=2)
printf("Hi");
else
printf("Bye");
Hi
what will be the output?
int x = 1 ;
while ( x == 1 ) {
x=x-1;
printf ( "%d", x ) ;
}
0
What will be the output for this code:
main( )
{
int a=1,b=0 ;
if(a||b)
printf("Hi");
if(a && b)
printf("Bye");
if(~b)
printf("Hello");
}
HiHello
What is the output from the following C code:
int x=1;
if(--x) printf("Hi"); else printf("Bye");
if(x=2) printf("Welcome"); else printf("Back");
if (x < 0); printf("again");
ByeWelcomeagain
What is the output from fhe following C code:
int m=5,n=10,q=20;
if(q/n*m)
printf("A");
else
printf("B");
printf("C");
AC
what is the output from the following C code:
int x = 3;
if(x == 2); x = 0;
if(x == 3) x++;
else x += 2;
printf("x = %d", x);
x = 2
what is the output, when the following C code is executed:
int i = 0;
do
{
printf("Hello");
i++;
} while(i > 1);
Syntax Error
Hello
Which of the following is the logical operator for logical-and?
&&
What keyword covers unhandled possibilities in a switch statement?
Default
Every switch construct can be replaced by a series of if-else statements
true
what is the output from the following C code:
int c = 1 ;
switch ( c )
{
case 1 :
printf ( “I ” ) ;
case 2 :
printf ( “Love ” ) ;
case 3:
printf ( “Programming”) ;
}
I Love Programming
Read the follow C code. How many times will “Great” be printed ?
int i = 64;
for(; i; i >>= 1)
printf(“Great”);
7
what is the output from the following C code:
int a=100;
if(a > 10)
printf(“Eric”);
else if(a > 20)
printf(“Philip”);
else if(a > 30)
printf(“Eva”);
Eric
What is the final value of x when the code
int x;
for(x=0; x<10; x++)
{
}
is run?
10
Which of the following is true in C?
all of them.
In an if-else statement, curly braces ({ }) can be ignored for the else part if the block contains only one statement.
true
An if-else statement (with else part) can be replaced by a set of if statements (without else part).
True
When does the code block following while(x<100) execute?
When x is less than one hundred
What is the result of the following code?
int x=0;switch(x){ case 1: printf( "One" ); case 0: printf( "Zero" ); case 2: printf( "Hello World" );}
ZeroHello World
when the following C code is executed, how many times "Hi" is printed?
int i = -5;
while(i <= 5)
{
if(i >= 0)
break;
else
{
i++;
continue;
}
printf(“Hi”);
}
0 times