Wednesday, March 7, 2012

Technical set 2

1.
What will be output when you will execute following c code?
#include<stdio.h>
void main(){
switch(5/2*6+3.0){
case 3:printf("David Beckham");
break;
case 15:printf("Ronaldinho");
break;
case 0:printf("Lionel Messi");
break;
default:printf("Ronaldo");
}
}
Choose all that apply:

(A) David Beckham
(B) Ronaldinho
(C) Lionel Messi
(D) Ronaldo
(E) Compilation error

Explanation:e
2.
What will be output when you will execute following c code?
#include<stdio.h>
void main(){
unsigned char c=280;
switch(c){
printf("Start\t");
case 280:printf("David Beckham\t");
case 24: printf("Ronaldinho\t");
default: printf("Ronaldo\t");
printf("End");
}
}
Choose all that apply:

(A)Start David Beckham Ronaldinho Ronaldo End
(B) Start David Beckham Ronaldinho Ronaldo
(C) Start Ronaldinho Ronaldo End
(D)Ronaldinho Ronaldo End

(E) Compilation error
Explanation:d
3.
What will be output when you will execute following c code?
#include<stdio.h>
#define TRUE 1
void main(){
switch(TRUE){
printf("cquestionbank.blogspot.com");
}
}

Choose all that apply:
(A) cquestionbank.blogspot.com
(B) It will print nothing
(C) Runtime error
(D) Compilation error
(E) None of the above

Explanation:b
4.
What will be output when you will execute following c code?
#include<stdio.h>
void main(){
static int i;
int j=1;
int arr[5]={1,2,3,4};
switch(arr[j]){
case 1: i++;break;
case 2: i+=2;j=3;continue;
case 3: i%=2;j=4;continue;
default: --i;
}
printf("%d",i);
}

Choose all that apply:
(A) 0
(B) 1
(C) 2
(D) Compilation error
(E) None of the above

Explanation:d
5.
What will be output when you will execute following c code?
#include<stdio.h>
void main(){
static int i;
int j;
for(j=0;j<=5;j+=2)
switch(j){
case 1: i++;break;
case 2: i+=2;
case 4: i%=2;j=-1;continue;
default: --i;continue;
}
printf("%d",i);
}

Choose all that apply:
(A) 0
(B) 1
(C) 2
(D) Compilation error

(E) None of the above
Explanation:a
6.
What will be output when you will execute following c code?
#include<stdio.h>
void main(){
int x=3;
while(1){
switch(x){
case 5/2: x+=x+++x;
case 3%4: x+=x---x;continue;
case 3>=3: x+=!!!x;break;
case 5&&0:x+=~~~x;continue;
default: x+=-x--;
}
break;
}
printf("%d",x);
}

Choose all that apply:
(A) 3
(B) -1
(C) 5
(D) Compilation error
(E) None of the above

Explanation:b
7.
What will be output when you will execute following c code?
#include<stdio.h>
void main(){
char *str="cquestionbank.blogspot.com";
int a=2;
switch('A'){
case 97:
switch(97){
default: str+=1;
}
case 65:
switch(97){
case 'A':str+=2;
case 'a':str+=4;
}
default:
for(;a;a--)
str+=8;
}
printf("%s",str);
}

Choose all that apply:
(A) cquestionbank.blogspot.com
(B) blogspot.com
(C) com
(D) Compilation error

(E) None of the above
Explanation:e
8.
What will be output when you will execute following c code?
#include<stdio.h>
void main(){
switch(2){
case 1L:printf("No");
case 2L:printf("%s","I");
goto Love;
case 3L:printf("Please");
case 4L:Love:printf("Hi");
}
}

Choose all that apply:
(A) I
(B) IPleaseHi
(C) IHi
(D) Compilation error
(E) None of the above

Explanation:c
9.
What will be output when you will execute following c code?
#include<stdio.h>
void main(){
int a=5;
a=a>=4;
switch(2){
case 0:int a=8;
case 1:int a=10;
case 2:++a;
case 3:printf("%d",a);
}
}
Choose all that apply:

(A) 8
(B) 11
(C) 10
(D) Compilation error
(E) None of the above

Explanation:e
10.
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:
(A) 10
(B) 11
(C) 12

(D)1
(E) Compilation error
Explanation:d

No comments:

Post a Comment