C programming MCQ


1.
Turbo C 3.0 is based on
(A) DOS
(B) UNIX
(C) Windows
(D) LINUX
(E) None


Explanation:
**

2.
Turbo C 4.5 is based on
(A) DOS
(B) UNIX
(C) Windows
(D) LINUX
(E) None


Explanation:
**

3.

Find the output of following c code?
#include<stdio.h>
int main(){
int a=4,b=5;
printit(a, b);
}
printit(int b, int a){
printf("%d %d", a, b);
{
int a=0;
int b=1;
printf("%d %d", a, b);
}
return 0;
} 


(A) 4 5 0 1
(B) 5 4 0 1
(C) 5 4 5 4
(D) None of these
(E) Compilation error

Explanation:
**

4.

The contents of a file will be lost if it is opened in

(A) a mode
(B) a- mode
(C) w+ mode
(D) a+ mode
(E) r mode


Explanation:
**

5.

Find the output of following c code.
#include<stdio.h>
int main(){
int i=1,j=2,k=3;
if(i==1)
if(j==2)
if(k==3){
printf("ok");
break;
}
else
printf("continue");
printf("bye");
return 0;


(A) ok
(B) okbye
(C) Misplaced break
(D) None of these
(E) It will print nothing


Explanation:
**

6.

Find the output of following c code.

#include<stdio.h>
int main(){
printf("C\question\bank");
return 0;
}

(A) Cquestionbank
(B) cuestionank
(C) cuestioank
(D) cquestioank
(E) None of these.


Explanation:
**

7.

What will be output if you will execute following c code?

#include<stdio.h>
int main(){
    char c=+'A';
    printf("%d",c);
return 0;
}

(A) 65
(B) 130
(C) Garbage value
(D) 0
(E) Compilation error


Explanation:
**

8.

What will be output if you will execute following c code?

#include<stdio.h>
int main(){
    int num,a=5;
    num=+++a;
    printf("%d  %d",num,a);
return 0;

}

(A) 5 5
(B) 6 6
(C) 7 7
(D) 5 6
(E)
Compilation error


Explanation:
**

9.

What will be output if you will execute following c code?

#include<stdio.h>
int main(){
    int num,a=10;
    num=a+++ +++a;
    printf("%d  %d",num,a);
return 0;

}

(A)
20 10
(B) 21 12 
(C) 22 12
(D) 21 11 
(E) Compilation error


Explanation:
**

10.

What will be output if you will execute following c code?

#include<stdio.h>
int main(){
    int z;
    z=5,3,2;
    printf("%d",z);
return 0;
}

(A)
5
(B) 3
(C)
2
(D) 10
(E) Compilation error


Explanation:
**

11.

What will be output if you will execute following c code?

#include<stdio.h>
int main(){
    int i=5,j=10,num;
    num=++i,++j,i+j;
    printf("%d  %d  %d",num,i,j);
return 0;
}

(A) 5 5 10
(B) 5 6 11
(C) 6 5 12
(D) 6 6 11
(E) Compilation error


Explanation:
**

12.

What will be output if you will execute following c code?

#include<stdio.h>
float avg(float,float,float);
int main(){
    float p=1,q=2,r=-2,a;
    a=avg(p,(q=4,r=-12,q),r);
    printf("%f",a);
return 0;
}
float avg(float x,float y,float z){
    return (x+y+z)/3;
}
(A) 1.000000
(B) 0.000000
(C) 0.333333
(D) 1.333333
(E) Compilation error


Explanation:
**

13.

What will be output if you will execute following c code?

int main(){
    char c='\x15';
    char *ptr=&c;
    printf("%x",*ptr);   
return 0;
}

(A)
0x15
(B) 0X15
(C) 21
(D) 0x21
(E) Compilation error


Explanation:
**

14.

What will be output if you will execute following c code?

#include<stdio.h>
int main(){
    char array[]="Ashfaq \0 Kayani";
    char *str="Ashfaq \0 Kayani";
    printf("%s %c\n",array,array[2]);
    printf("%s %c\n",str,str[2]);
    printf("%d %d\n",sizeof(array),sizeof(str));
return 0;
}

(A)
Ashfaq h
Ashfaq h
16 2
(B)
Ashfaq h
Ashfaq Kayani h
2 16
(C)
Ashfaq Kayani h
Ashfaq h
16 2
(D)
Ashfaq h
Ashfaq h
2 16
(E) Compilation error


Explanation:
**

15.

What will be output if you will execute following c code?

#include<stdio.h>
union myStruct{
    int a;
    char b;
};
int main(){
    union myStruct ms={400};
    printf("%d  %d",ms.a,ms.b);
    return 0;
}

(A) 400 0
(B) 0 400
(C) 80 -112
(D) 400 -112
(E) Compilation error


Explanation:
**

16.

#include<stdio.h>
union cqbu{
    int a;
    char b;
};
struct cqbs{
    int a;
    char b;
};
int main(){
    struct cqbs s={25,50};
    struct cqbs *ps=(struct cqbs *)&s;
    union  cqbu *pu=(union  cqbu *)&s;
    printf("%d  %d\n",ps->a,ps->b);
    printf("%d  %d\n",pu->a,pu->b);
    return 0;
}

(A)
25 50
25 25
(B)
25 50
50 50
(C)
25 25
25 50
(D)
50 50
50 25
(E)
Compilation error


Explanation:
**

17.

int main(){
    float x;
    x=(int(float(double)5.5));
    printf("%f",x);
    return 0;
}

(A) 5.5
(B) 5.500000
(C) 5.000000
(D) 6.000000
(E) Compilation error


Explanation:

18.

What will be output if you will execute following c code?

int main(){
    float x;
    (int)x=5.8f;
    printf("%f",x);
    return 0;
}

(A) 5.800000
(B) 6.000000
(C) 7.000000
(D) 5.8
(E) Compilation error


Explanation:
**

19.

What will be output if you will execute following c code?

#include<stdio.h>
int main(){
    int a=5,b=10,c=15;
    int *arr[3]={&a,&b,&c};
    printf("%d",*arr[*arr[1]-8]);
return 0;
}

(A) 5
(B) 10
(C) 18
(D) Garbage value
(E) Compilation error


Explanation:
**

20.

What will be output if you will execute following c code?

#include<stdio.h>
int main(){
    int arr[][3]={{1,2},{3,4,5},{5}};
    printf("%d %d %d",sizeof(arr),arr[0][2],arr[1][2]);
return 0;
}

(A) 6  0 4
(B) 6  1 5
(C) 18 0 5
(D) 18 1 5
(E) Compilation error


Explanation:
**


23 comments:

  1. I would like to receive answers of those questions on sayalip24@gmail.com

    ReplyDelete
  2. Shrikant Phale1/14/09, 6:16 PM

    open your TC paste ur code, compile, run, and see op.......and mail it at "sayalip24@gmail.com" :-]

    ReplyDelete
  3. We all came to same web page... [:D]

    ReplyDelete
  4. i would like to know the answers of these questions at m.muniba.k@gmail.com

    ReplyDelete
  5. I would like to recive answers of those questions on mounika.monu@gmail.com

    ReplyDelete
  6. it is very useful for students who are learning c language

    ReplyDelete
  7. please explain the answers of the questions.

    ReplyDelete
  8. please explain the answers as well.

    ReplyDelete
  9. ans of max ques are given wrong...acc to visual studio...

    ReplyDelete
  10. Answer of question no 7 is wrong..it should be option a

    ReplyDelete
    Replies
    1. yeah you are right......

      Delete
  11. paras:thanks

    ReplyDelete
  12. nooooo tooo good bcoz hme ni ateee

    ReplyDelete
  13. i want the full description of all program

    ReplyDelete
  14. explanation nahi diya be!!

    ReplyDelete
  15. Listen friend, A lot of companies pick out the questions for their written round from blogs such as yours. And a lot of them blindly take your answer as final without verifying it. So it is important that the answers you provide are correct. A lot of programs in this paper, though good compile differently on gcc i.e the Compiler used on Linux. So you need to make sure that the programs given here (Especially those involving Operator Precedence) are Compiler Independent.
    I noticed some of the outputs which I got don't even exist in the options. So I kindly request you to either modify the problems or remove them completely coz a single wrong anwer might make a difference between getting placed or getting rejected.

    Regards,
    Placement Executive @ BITS Pilani, Pilani Campus

    ReplyDelete
  16. verify the answer before finalizing since some answer are not correct....!

    ReplyDelete