Data structure/Data Structure and Algorithms (DSA) set 3 Sample Test,Sample questions

Question:
  How will you print
 on screen?

1.printf("\n");

2.printf(\ );

3. echo\\n;

4. printf("\\n");


Question:
 #include <stdio.h>
#include <string.h>
int main(){
int i=0;
for(;i<=2;)
printf(" %d",++i); return 0;
}

1. 0 1 2 3

2.0 1 2

3.1 2 3

4.compiler error


Question:
 a-> is systematically correct if_____

1.a is a pointer to a structure in which b is a field

2.a and b are structure

3. a is a structure and b is a pointer to a structure

4.a is a pointer to a structure and b is a structure


Question:
 Big O notation is defined for

1.time and space complexity

2.optimality

3.seaching

4.none of the above


Question:
 C language was invented by

1.abacus

2.charles babage

3.thomson

4.dennis ritchie


Question:
 The result of 0001 1010^0001 0000 is____

1.0101 1001

2.1010 0100

3.0000 0010

4.None of These


Question:
 Unsigned integers occupies

1.two bytes

2. four bytes

3.one bytes

4. eight bytes


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

1.8

2. 8

3.9

4.Compile error


Question:
 What will be output if you will compile and execute the following c code? #include<stdio.h> int main(){
int array[]={10,20,30,40};
printf("%d",-2[array]); return 0;
}

1.-60

2. -30

3.60

4.garbage value


Question:
 Which of the following data structure is linear type ?

1.strings

2.lists

3.queues

4.All of the above


Question:
 Which of the following statement is true about char ****a ?

1.a is pointer to a pointer to a pointer to char

2.a is pointer to a pointer to a pointer to char

3.a is a pointer to a char pointer

4.a is a pointer to a pointer to a char


Question:
. What is error in following declaration?
struct outer{ int a;
struct inner{
char c;
};
};

1. nesting of structure is not allowed in c

2.it is necessary to initialize the member variable

3. inner structure must have name

4.outer structure must have name


Question:
A node in a linked list must contain at least

1. three fields

2.two fields

3.four fields

4. one field


Question:
A variable which is visible only in the function in which it is defined, is called

1.static

2.auto

3.external

4.local


Question:
An algorithm is made up of two independent time complexities f (n) and g (n). Then the complexities of the algorithm is in the order of

1. f(n) x g(n)

2. max ( f(n),g(n))

3.min (f(n),g(n))

4. f(n) + g(n)


Question:
Are *ptr++ and ++*ptr are same?

1.no they are not same

2.yes they are one and the same

3. depends upon the value of ptr

4.None of These


Question:
Following function is used to find the first occurrence of given string in another string

1. strchar

2.strnset

3.strstr

4.strrchr


Question:
How many bits are absolutely necessary to store an ASCII character ?

1.7

2.8

3.15

4.16


Question:
If two string are identical then strcmp() function returns____

1. A. -1 B. 1 D. none of these

2.1

3.0

4.None of These


Question:
In C, if you pass an array as an argument to a function, what actually gets passed?

1.value of elements in array

2.first element of the array

3.base address of the array

4.address of the last element of array


Question:
In selection sort of n elements,how many times is the swp function called in the complete execution of the algorithm?

1.1

2. n-1

3.n(n-1)/2

4.none of these


Question:
Pointer is a___________

1. a keyword used to create a variable

2. a variable that stores the address of some instruction

3.a variable that stores the address of some other variable

4.All of the above


Question:
Queue is a -------------- List .

1. fifo

2.lifo

3.lilo

4.liso


Question:
The data type created by the data abstraction process is called

1.class

2.structure

3.abstract data type

4. user defined data type


Question:
The members of the union are accessed by____

1.dot operator

2.pointer -> operator

3.both a and b

4.None of These


Question:
The most significant bit is lost in following operation

1. <<

2. >>

3.&

4./


Question:
The result of 0001 1010 & 0000 1000 is ___

1. 0001 1111

2.1111 0001

3.0000 1000

4.None of These


Question:
The result of 0001 1010 >>2 is____

1.0101 1100

2. 0010 1110

3.0000 0110

4.None of These


Question:
The result of 0001 1010 << 2 is____

1. 0101 1100

2.0110 1000

3. 0001 1110

4.None of These


Question:
The result of 0001 1010 / 0001 0101 is

1. 0001 1111

2.1111 0001

3. 0001 0000

4.None of These


Question:
The result of 0001 1010 ~ 0100 0011 is

1.0101 1001

2.1010 0100

3.0000 0010

4.None of These


Question:
The result of i)true AND false II)false or false

1.i)is true and ii)is true

2. i)is true and ii)is false

3.i)is false and ii)is true

4. i)is false and ii)is false


Question:
The selection sort is basically a method of repeated

1.interchange

2.searching

3.position adjustment

4.None of These


Question:
What is the similarity between structure,union and enum?

1.all of them let you define new values

2.all of them let you define new pointers

3.all of them let you define new structure

4.all of them let you define new data types


Question:
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;
}

1.cquestionbank

2.cquestionbank\0

3.(null)

4.it will print nothing


Question:
What will be output if you will compile and execute the following c code? #include<stdio.h>
#define call(x,y) x##y
int main(){
int x=5,y=10,xy=20;
printf("%d",xy+call(x,y)); return 0;
}

1.35

2.510

3.15

4. 40


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

1.5

2.6

3.7

4.0


Question:
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;
}

1.343

2.27

3.133

4.compiler error


Question:
What will be output if you will compile and execute the following c code? #include<stdio.h>
int * call();
int main(){ int *ptr;
ptr=call();
printf("%d",*ptr); return 0;
} int * call(){
int a=25;
a++;
return &a;
}

1.25

2.26

3.any adress

4.garbage value


Question:
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;
}

1. 10hello world

2.11hello world

3. hello world12

4.hello world13


Question:
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;
}

1.135

2.+inf

3.-121

4.-8


Question:
What will be output if you will compile and execute the following c code? #include<stdio.h>
int main(){
double far* p,q;
printf("%d",sizeof(p)+sizeof q); return 0; }

1.12

2.8

3.4

4.1


Question:
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;
}

1.12 11 11

2.12 10 10

3. 11 11 12

4.10 10 12


Question:
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;

1. it will print nothing

2.-3

3.-2

4.compiler error


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

1.equal

2.less than

3.greater than

4.compiler error


Question:
What will be output if you will compile and execute the following c code? #include<stdio.h>
int main(){
int i=320;
char *ptr=(char *)&i;
printf("%d",*ptr); return 0;
}

1.320

2.1

3.64

4.None of the above


Question:
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;
}

1.21

2.18

3.12

4.Compile time error


Question:
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;
}

1.4

2.5

3.6

4.compiler error


Question:
What will be output if you will compile and execute the following c code? #include<stdio.h>
int main(){
printf("%d",sizeof(5.2)); return 0;
}

1.2

2.4

3.8

4.10


Question:
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;
}

1.equal

2.less than

3.greater than

4. compiler error


Question:
What will be the output of the following code? Int main(){char str[9]="My Computer";printf("%s
",str);return 0;}

1.mycompute

2.syntax error

3.runtime error

4.None of These


Question:
What will be the output of the following code? Int main(){printf("Hello","Word
");return 0;}

1.hello

2.hello world

3.world

4.none of these


Question:
Which data structure allows deleting data elements from front and inserting at rear?

1.stack

2.queue

3.dequeue

4.binary search tree


Question:
Which of the following can not be a structure member?

1.another structure

2. array

3.function

4.None of These


Question:
Which of the following data structure is linear type ?

1.strings

2.lists

3.queues

4. all of the above


Question:
Which of the following is a collection of different data type elements?

1.array

2.structure

3.string

4.all of the above


Question:
Which of the following is a collection of different data type elements?

1.array

2.structure

3.string

4.all of the above


Question:
Which of the following is a collection of different data type elements?

1.array

2.structure

3.string

4.All of the above


Question:
Which of the following is more appropriate for reading a multi_word string?

1. printf

2.scanf

3.put

4.gets


Question:
__operator is used to get the value stored at address stored in pointer variable

1. *

2. &

3.dot

4. +


More MCQS

  1. Data Structures and algorithms MCQ Questions
  2. Data Structure -Abstract Data Types
  3. Data Structure Questions and Answers Singly Linked
  4. Data Structures &algorithms MCQ Questions
  5. Data Structure Multiple Choice Questions and Answers
  6. Data Structure (DS) MCQ Set 1
  7. Data Structure (DS) MCQ Set 2
  8. Data Structure and Algorithms (DSA) set 1
  9. Data Structure and Algorithms (DSA) set 2
  10. Data Structure and Algorithms (DSA) set 3
  11. Data Structure and Algorithms (DSA) set 4
  12. Data Structure and Algorithms (DSA) set 5
  13. Linear Data Structures - List
  14. Data Structure MCQ questions and answer
  15. Data Structure MCQ questions and answer
Search
Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!