C Programming MCQ Multiple Choice Questions and Answers
1. What will be the value of x after executing the program ?
void main()
{
int x;
x=printf(“sbte”);
printf(“=%d”x);
}
{
int x;
x=printf(“sbte”);
printf(“=%d”x);
}
Answer : D
2. Find out the output for the following program
main()
{
do
printf(“I am in loop”);
while(4<3);
}
{
do
printf(“I am in loop”);
while(4<3);
}
Answer : B
3. Find out the output for the following program.
main()
{
int x=2,y=3;
printf(“%d%d”);
}
{
int x=2,y=3;
printf(“%d%d”);
}
Answer : C
4. Find out the output for the following program.
main()
{
int x=4;
if(x–2)
printf(“you are right”);
else
printf(“you are wrong”);
}
{
int x=4;
if(x–2)
printf(“you are right”);
else
printf(“you are wrong”);
}
Answer : C
5. What is the output of this C code ?
int main(void)
{
char a=’b’, b=’b’;
if(a==b)
printf(“I am happy”);
else
printf(“I am glad”);
return 0;
}
{
char a=’b’, b=’b’;
if(a==b)
printf(“I am happy”);
else
printf(“I am glad”);
return 0;
}
Answer : B
C Programming MCQ
6. What will be output of following C program?
int main(void)
{
int x=50;
printf(“%d,%d\n”,x=55,x>=10);
return 0;
}
{
int x=50;
printf(“%d,%d\n”,x=55,x>=10);
return 0;
}
Answer : D
7. What is the ouput of following program ?
int main()
{
printf(“%d”, 1);
goto 11;
printf(“%d”, 2);
11:goto 12;
printf(“%d”, 3);
12:printf(“%d”, 4);
}
{
printf(“%d”, 1);
goto 11;
printf(“%d”, 2);
11:goto 12;
printf(“%d”, 3);
12:printf(“%d”, 4);
}
Answer : D
8. What happens if you try to compile and run this program ?
int main(void)
{
char s[5]=”ABC”;
strcat(s+1, “ABC”);
printf(“%d”, s[0]-s[1]);
return 0;
}
{
char s[5]=”ABC”;
strcat(s+1, “ABC”);
printf(“%d”, s[0]-s[1]);
return 0;
}
Answer : A
9. What is the output of the following program ?
int main()
{
int *a, b;
b=1;
a=&b;
b=2;
printf(“%d\t”, b);
printf(“%d”, *a);
return 0;
}
{
int *a, b;
b=1;
a=&b;
b=2;
printf(“%d\t”, b);
printf(“%d”, *a);
return 0;
}
Answer : A
10. What is the value of the var variable at the end of the following snippet?
int var;
var=9;
var=var/2;
var=9;
var=var/2;
Answer : A
C Programming MCQ
11. The expression X=4+2%-8 evaluates to
Answer : B
12. Which of the following is the correct way of maiking comments in C ?
Answer : A
13. What happens if you try to compile and run this program ?
int main(void)
{
int i=2, j=1, k;
k=i>>j;
k<<=i;
printf(“%d”, k);
return 0;
}
{
int i=2, j=1, k;
k=i>>j;
k<<=i;
printf(“%d”, k);
return 0;
}
Answer : A
14. What will be the output of following program ?
main()
{
int x,y = 10;
x = y * NULL;
printf(“%d”,x);
}
{
int x,y = 10;
x = y * NULL;
printf(“%d”,x);
}
Answer : B
15. What will be the output of the following statements ?
int i = 3;
printf(“%d%d”,i,i++);
printf(“%d%d”,i,i++);
Answer : B
Related Links
- C++ Programming MCQs
- JAVA MCQs
- Visual Basic MCQs
- Data Structure MCQs
- Software Package MCQs
- Computer Organization and Architecture MCQs
- Operating System MCQs
- Digital Electronics MCQs
- DBMS MCQs
- System Analysis and Management Information System MCQs
- System Maintenance MCQs
- Data Communication and Networking MCQs
- Internet & Web Technology MCQs
- Software Engineering MCQs
- Management (Common) MCQs
This website is much helpful for us . Please provide more articles in C language.