Top 350+ Solved Data Structure and Algorithms (DSA) MCQ Questions Answer
Q. What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){float a=5.2;if(a==5.2)printf("Equal");else if(a<5.2)printf("Less than");elseprintf("Greater than"); return 0;}
a. equal
b. less than
c. greater than
d. compiler error
Q. What will be output if you will compile and execute the following c code? #include<stdio.h>int main(){int a=2;if(a==2){a=~a+2<<1;printf("%d",a);}else{break;} return 0;}
a. it will print nothing
b. -3
c. -2
d. compiler error
Q. What will be output if you will compile and execute the following c code? #include<stdio.h>int main(){int a=10;printf("%d %d %d",a,a++,++a); return 0;}
a. 12 11 11
b. 12 10 10
c. 11 11 12
d. 10 10 12
Q. What will be output if you will compile and execute the following c code? #include<stdio.h>int main(){char *str="Hello world";printf("%d",printf("%s",str)); return 0;}
a. 10hello world
b. 11hello world
c. hello world12
d. hello world13
Q. What will be output if you will compile and execute the following c code?#include <stdio.h>#include <string.h>int main(){char *str=NULL;strcpy(str,"cquestionbank");printf("%s",str); return 0;}
a. cquestionbank
b. cquestionbank\\0
c. (null)
d. it will print nothing
Q. #include <stdio.h>#include <string.h>int main(){int i=0;for(;i<=2;)printf(" %d",++i); return 0;}
a. 0 1 2 3
b. 0 1 2
c. 1 2 3
d. compiler error
Q. What is error in following declaration?struct outer{ int a;struct inner{char c;};};
a. nesting of structure is not allowed in c
b. it is necessary to initialize the member variable
c. inner structure must have name
d. outer structure must have name
Q. What will be output if you will compile and execute the following c code? #include<stdio.h>int main(){int i=10;static int x=i;if(x==i)printf("Equal");else if(x>i)printf("Greater than");elseprintf("Less than"); return 0;}
a. equal
b. less than
c. greater than
d. compiler error