1.
What will be output when you will execute following c code?
#include<stdio.h>
void main(){
int check=2;
switch(check){
case 1: printf("D.W.Steyn");
case 2: printf(" M.G.Johnson");
case 3: printf(" Mohammad Asif");
default: printf(" M.Muralidaran");
}
}
Choose all that apply:
Explanation:
If we will not use break
keyword in each case the program control will come in each case after the case witch
satisfy the switch condition.
20.
What will be output when you will execute following c code?
#include<stdio.h>
void main(){
int a=3,b=2;
a=a==b==0;
switch(1){
a=a+10;
}
sizeof(a++);
printf("%d",a);
}
Choose all that apply:
Explanation:
Consider on the
expression:
a=a==b==0;
a=(a==b)==0; //Since
associate is right to left
a =(3==2)==0
a=0==0
a=1
switch case will not
affect the value of variable a.
Also sizeof operator
doesn't affect the value of the any variable
(1)
What will be output of following
c code?
#include<stdio.h>
extern int x;
int main(){
do{
do{
printf("%o",x);
}
while(!-2);
}
while(0);
return 0;
}
int x=8;
Explanation
(2)
What will be output of following
c code?
#include<stdio.h>
int main(){
int i=2,j=2;
while(i+1?--i:j++)
printf("%d",i);
return 0;
}
Explanation
(3)
What will be output of following
c code?
#include<stdio.h>
int main(){
int x=011,i;
for(i=0;i<x;i+=3){
printf("Start ");
continue;
printf("End");
}
return 0;
}
Explanation
(4)What will be output of
following c code?
#include<stdio.h>
int main(){
int i,j;
i=j=2,3;
while(--i&&j++)
printf("%d %d",i,j);
return 0;
}
Explanation
(5)What will be output of
following c code?
#include<stdio.h>
int main(){
static int i;
for(++i;++i;++i) {
printf("%d ",i);
if(i==4) break;
}
return 0;
}
Explanation
(6)What will be output of
following c code?
#include<stdio.h>
int main(){
int i=1;
for(i=0;i=-1;i=1) {
printf("%d ",i);
if(i!=1) break;
}
return 0;
}
Explanation
(7)What will be output of
following c code?
#include<stdio.h>
int main(){
for(;;) {
printf("%d ",10);
}
return 0;
}
Explanation
(8)What will be output of
following c code?
#include<stdio.h>
int r();
int main(){
for(r();r();r()) {
printf("%d ",r());
}
return 0;
}
int r(){
int static num=7;
return num--;
}
Explanation
(9)What will be output of
following c code?
#include<stdio.h>
#define p(a,b) a##b
#define call(x) #x
int main(){
do{
int i=15,j=3;
printf("%d",p(i-+,+j));
}
while(*(call(625)+3));
return 0;
}
Explanation
(10)
#include<stdio.h>
int main(){
int i;
for(i=0;i<=5;i++);
printf("%d",i)
return 0;
}
Explanation
(11)What will be output of
following c code?
#include<stdio.h>
int i=40;
extern int i;
int main(){
do{
printf("%d",i++);
}
while(5,4,3,2,1,0);
return 0;
}
Explanation
(12)What will be output of
following c code?
#include<stdio.h>
char _x_(int,...);
int main(){
char (*p)(int,...)=&_x_;
for(;(*p)(0,1,2,3,4); )
printf("%d",!+2);
return 0;
}
char _x_(int a,...){
static i=-1;
return i+++a;
}
Explanation
(13)What will be output of
following c code?
#include<stdio.h>
int main(){
int i;
for(i=10;i<=15;i++){
while(i){
do{
printf("%d
",1);
if(i>>1)
continue;
}while(0);
break;
}
}
return 0;
}
Explanation
(14)How many times this loop will
execute?
#include<stdio.h>
int main(){
char c=125;
do
printf("%d ",c);
while(c++);
return 0;
}
Explanation
(15)What will be output of
following c code?
#include<stdio.h>
int main(){
int x=123;
int i={
printf("c" "++")
};
for(x=0;x<=i;x++){
printf("%x ",x);
}
return 0;
}