Wednesday, March 7, 2012

Technical set 1

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:
(A)    M.G.Johnson   
(B)    M.Muralidaran   
(C)   
M.G.Johnson Mohammad Asif M.Muralidaran
(D)    Compilation error   
(E)    None of the above   
Explanation:c
2.
What will be output when you will execute following c code?#include<stdio.h>
void main(){
     int movie=1;
     switch(movie<<2+movie){
        default:printf("3 Idiots");
        case 4: printf(" Ghajini");
        case 5: printf(" Krrish");
        case 8: printf(" Race");
     }
}
Choose all that apply:
(A)    3 Idiots Ghajini Krrish Race   
(B)    Race   
(C)    Krrish   
(D)    Ghajini Krrish Race   
(E)    Compilation error   
Explanation:b
3.
What will be output when you will execute following c code?#include<stdio.h>
#define L 10
void main(){
     auto money=10;
     switch(money,money*2){
        case L:  printf("Willian");
                  break;
        case L*2:printf("Warren");
                  break;
        case L*3:printf("Carlos");
                  break;
        default: printf("Lawrence");
        case L*4:printf("Inqvar");
                  break;
     } 
}
Choose all that apply:
(A)    Willian   
(B)    Warren   
(C)    Lawrence Inqvar   
(D)    Compilation error: Misplaced default   
(E)    None of the above   
Explanation:b
4.
What will be output when you will execute following c code?#include<stdio.h>
void main(){
     int const X=0;
     switch(5/4/3){
        case X:  printf("Clinton");
                  break;
        case X+1:printf("Gandhi");
                  break;
        case X+2:printf("Gates");
                  break;
        default: printf("Brown");
     }
}
Choose all that apply:
(A)    Clinton   
(B)    Gandhi   
(C)    Gates   
(D)    Brown   
(E)    Compilation error   
Explanation:e
5.
What will be output when you will execute following c code?#include<stdio.h>
enum actor{
    SeanPenn=5,
    AlPacino=-2,
    GaryOldman,
    EdNorton
};
void main(){
     enum actor a=0;
     switch(a){
        case SeanPenn:  printf("Kevin Spacey");
                         break;
        case AlPacino:  printf("Paul Giamatti");
                         break;
        case GaryOldman:printf("Donald Shuterland");
                         break;
        case EdNorton:  printf("Johnny Depp");
     } 
}
Choose all that apply:
(A)    Kevin Spacey   
(B)    Paul Giamatti   
(C)    Donald Shuterland   
(D)    Johnny Depp   
(E)    Compilation error   
Explanation:d
6.
What will be output when you will execute following c code?
#include<stdio.h>
void main(){
     switch(*(1+"AB" "CD"+1)){
        case 'A':printf("Pulp Fiction");
                  break;
        case 'B':printf("12 Angry Man");
                  break;
        case 'C':printf("Casabance");
                  break;
        case 'D':printf("Blood Diamond");
     }
}
Choose all that apply:
(A)    Pulp Fiction   
(B)    12 Angry Man   
(C)    Casabance   
(D)    Blood Diamond   
(E)    Compilation error   
Explanation:c
7.
What will be output when you will execute following c code?#include<stdio.h>
void main(){
    char *str="ONE"
    str++;
    switch(str){
        case "ONE":printf("Brazil");
                break;
        case "NE": printf("Toy story");
                break;
        case "N":  printf("His Girl Friday");
                break;
        case "E":  printf("Casino Royale");
     } 
}
Choose all that apply:
(A)    Brazil   
(B)    Toy story   
(C)    His Girl Friday   
(D)    Casino Royale   
(E)    Compilation error   
Explanation:e
8.
What will be output when you will execute following c code?#include<stdio.h>
void main(){
    switch(5||2|1){
        case 3&2:printf("Anatomy of a Murder");
              break;
        case -~11:printf("Planet of Apes");
               break;
        case 6-3<<2:printf("The conversation");
               break;
    case 5>=5:printf("Shaun of the Dead");
     }
}
Choose all that apply:
(A)    Anatomy of a Murder   
(B)    Planet of Apes   
(C)    The conversation   
(D)    Shaun of the Dead   
(E)    Compilation error   
Explanation:e
9.
What will be output when you will execute following c code?#include<stdio.h>
void main(){
    switch(6){
        case 6.0f:printf("Sangakkara");
               break;
        case 6.0: printf("Sehwag");
               break;
        case 6.0L:printf("Steyn");
               break;
        default:  printf("Smith");
    }
}
Choose all that apply:
(A)    Sangakkara   
(B)    Sehwag   
(C)    Steyn   
(D)    Smith   
(E)    Compilation error   
Explanation:e
10.
What will be output when you will execute following c code?
#include<stdio.h>
void main(){
    switch(0X0){
        case NULL:printf("Thierry Henry");
             break;
        case '\0':printf("Steven Gerrend");
             break;
        case 0: printf("Kaka");
             break;
        default: printf("Michael Ballack");
    }
}
Choose all that apply:
(A)    Thierry Henry   
(B)    Steven Gerrend   
(C)    Kaka   
(D)    Michael Ballack   
(E)    Compilation error   
Explanation:e

No comments:

Post a Comment