Following are the multiple choice questions and answers on C language Control structure that includes decision, Looping and jumping control structure.
1) What will be the output of following program ?
#include<stdio.h>
int main( )
{
int a=300,b,c;
if(a>=400)
b=300;
c=200;
printf("%d,%d\n",b,c);
return 0;
}
#include<stdio.h>
int main( )
{
int x=10,y=20;
if(x = = y)
printf("%d%d",x,y);
return 0;
}
#include<stdio.h>
int main( )
{
int x=3;
float y=3.0;
if(x = = y)
printf(" x and y are equal");
else
printf(" x and y are not equal");
}
#include<stdio.h>
int main( )
{
int x=3,y,z;
y=x=10;
z=x<10;
printf("x=%dy=%dz=%d\n",x,y,z);
return 0;
}
#include<stdio.h>
int main( )
{
int k=35;
printf("%d%d%d",k==35,k=50,k>40);
}
#include<stdio.h>
void main( )
{
int i=0;
for(;i;)
printf("Allquiz");
}
#include<stdio.h>
void main( )
{
int i;
for(i=1;i<=5;printf("%d",i));
i++
}
#include<stdio.h>
int main( )
{
int x=4;
while(x==1)
{
x=x-1;
printf("%d",x);
x--;
}
}
1) What will be the output of following program ?
#include<stdio.h>
int main( )
{
int a=300,b,c;
if(a>=400)
b=300;
c=200;
printf("%d,%d\n",b,c);
return 0;
}
- Garbage value, Garbage Value
- 300,200
- 200,300
- Garbage value,200
Show/Hide Answer
Answer = D
Explanation: As the condition within the if statement is false so the value of b will not be initialized so it will print the garbage value and c is initialized to 200 so the output will be Garbage,200
2) What will be the output of following code ?Explanation: As the condition within the if statement is false so the value of b will not be initialized so it will print the garbage value and c is initialized to 200 so the output will be Garbage,200
#include<stdio.h>
int main( )
{
int x=10,y=20;
if(x = = y)
printf("%d%d",x,y);
return 0;
}
- Garbage values
- Raise an error
- Prints Nothing
- None of above
Show/Hide Answer
Answer = C
Explanation:As the condition of if statement is not true, so the statement immediately after if that is print statement will not be executed and the code prints nothing.
3) Give the output of following code ?Explanation:As the condition of if statement is not true, so the statement immediately after if that is print statement will not be executed and the code prints nothing.
#include<stdio.h>
int main( )
{
int x=3;
float y=3.0;
if(x = = y)
printf(" x and y are equal");
else
printf(" x and y are not equal");
}
- x and y are equal
- x and y are not equal
- x and y are same
- None of above
Show/Hide Answer
Answer = A
4) What will be the output of code ?#include<stdio.h>
int main( )
{
int x=3,y,z;
y=x=10;
z=x<10;
printf("x=%dy=%dz=%d\n",x,y,z);
return 0;
}
- 10,10,10
- 10,10,0
- 0,0,0
- 0,10,10
Show/Hide Answer
Answer = B
5) What will be the output ?#include<stdio.h>
int main( )
{
int k=35;
printf("%d%d%d",k==35,k=50,k>40);
}
- 35,50,40
- 0,50,0
- 0,0,0
- 1,1,1
Show/Hide Answer
Answer =B
6) Which of the following statement is used to take the control to the beginning of the loop ?- exit
- break
- continue
- None of these
Show/Hide Answer
Answer = C
7) A do - while loop is useful when we want that the statement within the loop must be executed ?- only once
- at least once
- more than once
- None of above
Show/Hide Answer
Answer = B
8) What will the output of following program ?#include<stdio.h>
void main( )
{
int i=0;
for(;i;)
printf("Allquiz");
}
- Prints Nothing
- Raise an error
- Garbage value
- Allquiz
Show/Hide Answer
Answer = A
9) What will be the output of following program ?#include<stdio.h>
void main( )
{
int i;
for(i=1;i<=5;printf("%d",i));
i++
}
- Error
- Garbage values
- 1 to 5
- Infinite loop
Show/Hide Answer
Answer =D
10) What will be the output of following program ?#include<stdio.h>
int main( )
{
int x=4;
while(x==1)
{
x=x-1;
printf("%d",x);
x--;
}
}
- 4
- 1,2,3,4
- Prints Nothing
- None of above
Show/Hide Answer
Answer =C
Do You Like This? Please take 5 seconds to share with your firends.
0 comments:
Post a Comment