Data Structure and Algorithms (DSA) MCQs with answers Page - 28

Here, you will find a collection of MCQ questions on Data Structure and Algorithms (DSA). Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833.24K Points
Coach

Q. What will be output if you will compile and execute the following c code? #include<stdio.h>
#define x 5+2
int main(){
int i;
i=x*x*x;
printf("%d",i); return 0;
}

  • (A) 343
  • (B) 27
  • (C) 133
  • (D) compiler error

A

Admin • 833.24K Points
Coach

Q. What will be output if you will compile and execute the following c code? #include<stdio.h>
int main(){
char c=125;
c=c+10;
printf("%d",c); return 0;
}

  • (A) 135
  • (B) +inf
  • (C) -121
  • (D) -8

A

Admin • 833.24K Points
Coach

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");
else
printf("Greater than"); return 0;
}

  • (A) equal
  • (B) less than
  • (C) greater than
  • (D) compiler error

A

Admin • 833.24K Points
Coach

Q. What will be output if you will compile and execute the following c code? #include<stdio.h>
int main(){
int i=4,x;
x=++i + ++i + ++i;
printf("%d",x); return 0;
}

  • (A) 21
  • (B) 18
  • (C) 12
  • (D) compiler error

A

Admin • 833.24K Points
Coach

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

A

Admin • 833.24K Points
Coach

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

A

Admin • 833.24K Points
Coach

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

A

Admin • 833.24K Points
Coach

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

A

Admin • 833.24K Points
Coach

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

A

Admin • 833.24K Points
Coach

Q. What will be output if you will compile and execute the following c code? #include<stdio.h>
int main(){
int x;
for(x=1;x<=5;x++);
printf("%d",x); return 0;
}

  • (A) 4
  • (B) 5
  • (C) 6
  • (D) compiler error

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ