c intrroduction

37
C intrroduction: 1) What will be output when you will execute following c code? #include<stdio.h> int main(){ printf("%d\t",sizeof(6.5)); printf("%d\t",sizeof(90000)); printf("%d",sizeof('A')); return 0; } Choose all that apply: (A ) 4 2 1 (B ) 8 2 1 (C ) 4 4 1 (D ) 8 4 1 (E ) 8 4 2 ANS: E 2) Which of the following is not modifier of data type in c? (A ) extern (B ) interrupt (C ) huge (D ) register (E All of these are modifiers of data type

Upload: anusanrd

Post on 15-Oct-2014

81 views

Category:

Documents


2 download

TRANSCRIPT

C intrroduction:

1) What will be output when you will execute following c code?

#include<stdio.h>int main(){    printf("%d\t",sizeof(6.5));    printf("%d\t",sizeof(90000));    printf("%d",sizeof('A'));    return 0;}

Choose all that apply:

(A) 4 2 1

(B) 8 2 1 

(C) 4 4 1

(D) 8 4 1

(E) 8 4 2

ANS: E

2) Which of the following is not modifier of data type in c?

(A) extern

(B) interrupt

(C) huge

(D) register

(E) All of these are modifiers of data typeANS:E

3) What will be output when you will execute following c code?

#include<stdio.h>int main(){    const int *p;    int a=10;    p=&a;    printf("%d",*p);    return 0;}

Choose all that apply:

(A) 0

(B) 10

(C) Garbage value

(D) Any memory address

(E) Error: Cannot modify const objectANS: B

4) Consider on following declaration:(i)        short i=10;(ii)      static i=10;(iii)    unsigned i=10;(iv)      const i=10;

Choose correct one:

(A) Only (iv) is incorrect

(B) Only (ii) and (iv) are incorrect

(C) Only (ii),(iii) and (iv) are correct

(D) Only (iii) is correct

(E)All are correct declaration 

ANS: E

5) Which of the following is integral data type?

(A) void

(B) char

(C) float

(D) double

(E) None of theseANS :B

6) Which of the following is not derived data type in c?

(A) Function

(B) Pointer

(C) Enumeration

(D) Array

(E) All are derived data typeANS: C.

7) Consider on following declaration in c:

(i)short const register i=10;(ii)static volatile const int i=10;(iii)unsigned auto long register i=10;(iv)signed extern float i=10.0;

Choose correct one:

(A) Only (iv)is correct

(B) Only (ii) and (iv) is correct

(C) Only (i) and (ii) is correct

(D) Only (iii) correct

(E) All are correct declaration ANS :C

11) What will be output when you will execute following c code?

#include<stdio.h>void main(){    int a=5,b=10,c=1;    if(a&&b>c){         printf("cquestionbank");    }    else{         break;    }}

Choose all that apply:

(A)  cquestionbank

(B)  It will print nothing

(C)  Run time error

(D)   Compilation error

(E)  None of the above ANS:D

12) What will be output when you will execute following c code?

#include<stdio.h>void main(){    int m=5,n=10,q=20;    if(q/n*m)         printf("William Gates");    else         printf(" Warren Buffet");         printf(" Carlos Slim Helu");}

Choose all that apply:

(A)  William Gates

(B)   Warren Buffet Carlos Slim Helu

(C)  Run time error

(D)  Compilation error

(E)  None of the aboveANS: E

13) What will be output when you will execute following c code?

#include<stdio.h>void main(){    if(!printf("Mukesh Ambani"))    if(printf(" Lakashmi Mittal"));}

Choose all that apply:

(A)  Mukesh Ambani

(B)   Lakashmi Mittal

(C)  It will print nothing

(D)  Mukesh Ambani Lakashmi Mittal

(E)  Compilation error: if statement without bodyANS: A

14) What will be output when you will execute following c code?

#include<stdio.h>void main(){    if(0xA)         if(052)             if('\xeb')                 if('\012')                      printf("Tom hanks");                 else;             else;         else;    else;}

Choose all that apply:

(A)  Tom hanks

(B)  Compilation error: Misplaced else

(C)  Compilation error: If without any body

(D)  Compilation error: Undefined symbol

(E)  Warning: Condition is always trueANS: A,E

15) What will be output of following program?

#include<stdio.h>int main(){   int a = 320;   char *ptr;   ptr =( char *)&a;   printf("%d ",*ptr);

   return 0;}(A) 2

(B) 320

(C) 64

(D) Compilation error

(E) None of aboveANS : c

16) What will be output of following program?

#include<stdio.h>#include<conio.h>int main(){   void (*p)();   int (*q)();   int (*r)();   p = clrscr;   q = getch;   r = puts;  (*p)();  (*r)("cquestionbank.blogspot.com");  (*q)();  return 0;}

(A) NULL

(B) cquestionbank.blogspot.com

(C) c

(D) Compilation error

(E) None of aboveAns :B

17) What will be output of following program?

#include<stdio.h>int main(){   int i = 3;   int *j;

   int **k;   j=&i;   k=&j;   printf("%u %u %d ",k,*k,**k);   return 0;}(A) Address, Address, 3

(B) Address, 3, 3

(C) 3, 3, 3

(D) Compilation error

(E) None of aboveANS :A

18) What will be output when you will execute following c code?

#include<stdio.h>void main(){    char arr[7]="Network";    printf("%s",arr);}Choose all that apply:(A) Network

(B) N

(C) Garbage value

(D) Compilation error

(E) None of the aboveANS :C

19) WWhat will be output when you will execute following c code?

#include<stdio.h>void main(){    char arr[11]="The African Queen";    printf("%s",arr);}

Choose all that apply:

(A) The African Queen

(B) The

(C) The African

(D) Compilation error

(E) None of the aboveANS : D

20) What will be output when you will execute following c code?

#include<stdio.h>void main(){    int const SIZE=5;    int expr;    double value[SIZE]={2.0,4.0,6.0,8.0,10.0};    expr=1|2|3|4;    printf("%f",value[expr]);}

Choose all that apply:(A) 2.000000

(B) 4.000000

(C) 8.000000

(D) Compilation error

(E) None of the aboveANS : D

21)  What will be output of following c code?

void main(){

struct employee{unsigned id: 8;unsigned sex:1;unsigned age:7;};struct employee emp1={203,1,23};clrscr();

printf("%d\t%d\t%d",emp1.id,emp1.sex,emp1.age);getch();

}A) 205,NULL,21 B) 203 1 23

ANS: B22)  What will be output of following c code?

void main(){

struct bitfield{unsigned a:3;char b;unsigned c:5;int d;}bit;clrscr();printf("%d",sizeof(bit));getch();

}A) 6 B) 5 C) 4

Output: B23) What will happen if you execute following program?

#include<stdio.h>int main(){    FILE *fp1,*fp2;        fp1=fopen("day.text","r");    fp2=fopen("night.txt","r");    fclose(fp1,fp2);    return 0;}

A) RUNTIME ERROR B) COMPILER ERRORANS :B

24) What will be output when you will execute the following program?

#include<stdio.h>union A{

char p;float const * const q;

};int main(){    union A arr[10];    printf("%d",sizeof arr);   return 0;      }

A) 10 B) 20ANS :B

25) What will be output when you will execute the following program?

#include<stdio.h>union A{    char character;    int ascii;};int main(){    union A arr[2]={{65},{'a'}};    printf("%c %c",arr[0],arr[1]);

       return 0;      }

A) A a B) A AANS : A

DATA STRUCTURES:1) In linked lists there are noNULL links in:

a. Single linked listb. Linear doubly linked listc. circular linked listd. None of the above

ANS : C

2) The dummy header in linked list contain

a. First record of the actual datab. Last record of the actual datac. Pointer to the last record of the actual datad. None of the above

ANS: A

3) How many pointers are contained as data members in the nodes of a circular, doubly linked list of integers with five nodes?

a. 5

b. 8c. 10d. 15ANS c. 10

4) In a Stack the command to access nth element from the top of the stack s will be

e. S[Top-n]f. S [Top+n]g. S [top-n-1]h. None of the above

ANS: A5) The result of evaluating prefix expression */b+-dacd, where a = 3, b = 6, c = 1, d = 5 is

a. 0b. 5c. 10d. 15

ANS: C

6) Which of the following statements about stacks is incorrect?

a. Stacks can be implemented using linked lists.

b. Stacks are first-in, first-out (FIFO) data structures.

c. New nodes can only be added to the top of the stack.

d. The last node (at the bottom) of a stack has a null (0) link.

ANS b. Stacks are first-in, first-out (FIFO) data structures.

7) Which of the following is not a dynamic data structure?

a. Linked list.

b. Stack.

c. Array.

d. Binary tree.

ANS c. Array

8) At most, how many comparisons are required to search a sorted vector of 1023 elements using the binary search algorithm?

a. 10

b. 15

c. 20

d. 30

ANS a. 10

9) Which of the following represents the efficiency of the insertion sort?

a. O(1)

b. O(log n)

c. O(n)

d. O(n

2

)

ANS: d. O(n2)

10) In general, linked lists allow:

a. Insertions and removals anywhere.

b. Insertions and removals only at one end.

c. Insertions at the back and removals from the front.

d. None of the above.

ANS a. Insertions and removals anywhere.

11) Which data structure represents a waiting line and limits insertions to be made at the back of the data structure and limits removals to be made from the front?

a. Stack.

b. Queue.

c. Binary tree.

d. Linked liST

ANS b. Queue

12) Given that the line

delete newPtr;

just executed, what can you conclude?

a. The memory referenced by newPtr is released only if it is needed by the system.

b. The pointer newPtr is of type void *.

c. The pointer newPtr only exists if there was an error freeing the memory.

d. The pointer newPtr still exists.

ANS d. The pointer newPtr still exists

13) Select the incorrect statement. Binary search trees (regardless of the order in which the values are inserted into The tree.

a. Always have multiple links per node.

b. Can be sorted efficiently.

c. Always have the same shape for a particular set of data.

d. Are nonlinear data structures.

ANS: c. Always have the same shape for a particular set of data.

14) The data structure has the following components

Choose one answer.

a. Algorithm, storage structure and function of implementationThree element that form a data structure are: Algorithm, Storage Structure , Function

b. Algorithm, data type and function of implementation

c. Function, storage structure and program

d. Algorithm, data structure and program ANS: A 15) In linked list, the successive element

a. Must occupy contiguous locations in memory

b. Need not occupy contiguous space in memory Link list always occupies random memory allocation

c. Must not occupy contiguous locations in any situation

d. None of the above ANS: B 16) Link pointer variable in linked list contain address of the

a. Following node in the list Link list connect together with address

b. Current node in the list

c. First node in the list

d. None of the above ANS :A================================================17) Which of the following liner list structure allow both insertion and deletion at only one end?

a. Queue

b. Stack Stack is onside open to insert and delete like a bottle

c. Circular queue

d. None of the above ANS :B================================================18) Pick out invalid statement from following : Queues can be used for

a. The line printer Queue is like a pipe with one entrance for ENTRY and other end for EXIT

b. Access to disk storage

c. Function call d. Main Memory Access ANS: A

19) When PUSH operation is done then

a. TOP=TOP+1 The pointer TOP is incremented by one , Initially TOP

b. -1

c. TOP= TOP-1

d. TOP=-1

e. TOP=0 ANS: A================================================20) When POP operation is done thena. TOP=TOP+1

b. TOP= TOP-1 The pointer TOP is decremented by

c. TOP=-1

d. TOP=0 ANS : B 21) In Stack we insert data from:

a. Front End

b. Rear End

c. Both End

d. Top End Stack has only one end called Top End, No Front ,No Rear ANS: D

22) The Stack overflow occurs when

a. When stack contains maximum elements The stack when unable to add more elements

b. When stack contains minimum elements

c. When stack contains half of the maximum elements

d. When stack is empty ANS: A================================================23 ) If the in-order pre-order traversal of a binary tree are D,B,F,E,G,H,A,C and A,B,D,E,F,G,H,C respectively then post order will be:

a. D,F,G,A,B,C,H,E

b. F,H,D,G,E,B,C,A

c. D,F,H,G,E,B,C,A For Post order the algorithm is LEFT

d. C,G,H,F,E,D,B,A ANS: C================================================24) Stack is useful for implementing breadth first search

a. True

b. False We cannot use stack for breath first search ANS : B 25) We can change the insertion position of the Stack

a. Yes

b. No The stack cannot be reversed ANS: B 27) In the Sack STACK_SIZE is :

a. Fixed The size of the stack is fixed at the time of creation, it cannot be changed at runtime

b. Variable ANS:A

28) Stack maintains the algorithm

a. LIFO

b. FIFO

c. FILO

d. LILO ANS:A 29) The stack is easy to maintain by

a. Array No insertion and deletion is made in between the stack, only from one end-Array is easy

b. Link List

c. Structure

d. Union ANS:A 30 ) The Polish Notation is

. a. Post order

b. Pre order The pre order is called polish Notation.

c. In order

d. None of these ANS:B

31) Infix to post fix conversion we need :

a. Stack A stack is required to hold the operators

b. Queue

c. Structure

d. Union ANS:A 32) stack cannot be used to

a. evaluate an arithmetic expression in postfix form

b. implement recursion

c. convert infix form to postfix from of an expression

d. allocate resources by operating system For random memory allocation we cannot use stack ANS:D34) Application of Stack is :

a. Function Call For function call stack operation is needed

b. Storage data in memory

c. Dynamic memory allocation

d. Structure definition ANS: A

35) Requirement of Polish Notation

a. Because the notation does not have any priority The notation does not have any priority so it is used in expression evaluation

b. Because the notation have priority ANS: A

36) The priority queue requires FRONT and REAR:

a. One only

b. Multiple To maintain different priority , Queue required number of FRONT and REAR pointers c. None

d. Two only ANS: B 37) Which of the following data structure may give overflow error, even though the current number of elements in it is less than its size?

a. stack

b. circular queue

c. simple queue The queue has two pointer front and rear for insert and delete elements

d. none of the above ANS: A 38) The basic problem of space utilization has been removed by

a. Stack

b. Circular Queue The circular queue circulate the pointer so it utilise the queue spaces

c. Double Ended Queue

d. Queue Size ANS: B

39) What algorithm is used in Queue?

a. FILO

b. LILO

c. FIFO The queue has Front and Rear end for Delete and Insert elements

d. LIFO ANS: C

40) From which end of Queue elements are deleted?

a. Rear

b. Front The delete elements from Front end only.

c. Middle Position

d. Any position of the queue ANS: B

41) The access of Queue elements is

a. Sequential The elements of the Queue is one after another , so its access is sequential

b. Random

c. Direct

d. Indexed ANS: A 42) What is the difference between Stack & Queue?

a. Storage Structure

b. Memory Allocation

c. Algorithm The main algorithm differs between Stack and Queue

d. All of the Above ANS: C 43) Queue can be represented by

a. Array

b. Link List

c. Tree

d. Only a) and b) We can represent Queue by array and link list also ANS: D

44) The Queue Size can be:

a. Dynamically changed

b. Static, cannot he changed The size of the queue is fixed when created ANS:B

45) One Application of Priority Queue is

a. CPU scheduling CPU scheduling sometimes uses priority based scheduling

b. Ready Queue for printing

c. Data Access from RAM

d. Reading data through Scanner ANS: A 46)Queue is :

a. Linear Data Structure Queue is continuous sequential so it is linear data structure

b. Non Linear Data Structure ANS: B 46) Queue is easy to implement by

a. Array Queue operation cannot use random access of elements so it is easy by array

b. Link List

c. Structure

d. Union ANS: A 47) In Circular Link List

a. Head node contains the address of tail node

b. Tail node contains the address of the head To make the list circular, tail node contains the address of head

c. Head node contains the address of the middle node

d. Tail node contains the address of the middle node ANS: B 48) In Doubly Linked List each node contains

a. No address part

b. One address part

c. Two address part The double linked list node holds the address of previous and next node, so two address part

d. Three address part ANS: C

49) Linked List is

a. Linear Data Structure The linked list contains sequential of nodes so it is linear structure

b. Non Linear Data Structure ANS: A 50) To create linked list created by

a. Structure By using structure we can connect one node to another

b. Union

c. Array

d. Macro ANS: A

51) We can traverse in either direction

a. Singular Linked List

b. Circular Linked List

c. Doubly Linked List The doubly linked list node holds address of previous and next node address.

d. Tree Linked List ANS: C

52) The application of Linked List

a. Add two characters

b. Add two large numbers To add two large numbers we use linked list

c. Add two Strings

d. Add two very small numbers ANS: B 53) Each node of linked list has two parts

a. Data & Address The linked list has two parts data and address to hold the other node

b. Data & Null

c. Address & Null

d. Address & Address ANS: A 54) Linked List allocate memory space in

a. Direct fashion

b. Contiguous fashion

c. Random fashion The linked list allocates memory space in random order

d. Indexed fashion ANS: C 55) Can we delete the head node from Doubly Linked List

a. True The second node will be the head node

b. False ANS:A

56) Advantage of Linked List over array

a. Linked List occupies less memory

b. Linked List can be stored in disk

c. Deletion of nodes is easy than array The deletion of node is easy over array, array does not have direct deletion option

d. Linked List is easy to maintain ANS: C

57) Number of all possible binary trees with 2 nodes is

a. 1

b. 2 By changing the passion we get only two possible ways

c. 3

d. 4 58) Binary tree and Binary Search Tree are same

a. True

b. False Correct, the additional feature of binary search tree is order ANS: B 59) Which of the following statements is TRUE? A B-Tree of order

a. 24 contains at least 12 key in each non root node.

b. 25 contains at least 12 keys in each node

c. 24 contains at least 23 keys in each non root node One node contains one less than the order of that tree. So it is24

d. None of the above. ANS: C 60) What is the minimum number of keys contained in each non root node of a B-Tree of order 11?

a. 4

b. 5 The value will be 5 because when the node splits from median then it contains half of the nodes in the either side of the nodes.

c. 3

d. 1 ANS: B

61) Binary Tree Traversal is faster in

a. Ordinary Binary Tree

b. Binary Search Tree

c. Threaded Binary d. AVL Tree ANS: C

62) Full Binary Tree and Complete Binary Tree are same

a. True

b. False ANS: B63) If the degree of a node if 0 then the tree is called

a. Trinary Tree

b. Single Edged tree

c. Single node tree Single node tree does not have any edge so it is possible

d. Single degree tree ANS: C 64) To traverse from one node to another in the tree

a. There may be many path

b. There may be only one PATH

65) The Polish Notation is

a. Prefix notation Prefix is the polish notation

b. Postfix notation

c. Infix notation

d. All of the above ANS: A 66) In complete binary tree the number of nodes in level 0 is

a. 0

b. 1 The formula to obtain the number of nodes is 2n

c. 2

d. 3 ANS: B 67) In the tree which node has not child called

a. Root node

b. Leaf node Leaf node does not have child

c. Parent node

d. Internal node ANS: B 68) Spanning Tree related to

a. Kruskal's Algorithm Correct! It is the right answer

b. Piterson's Algorithm

c. Newton's Algorithm

d. Ratherford's Algorithm ANS: A

69) What is the average number of comparisons in linear search

a. (n+1)/2

b. (2n+1)/2

c. (n+1)

d. 2(n+1) ANS: A

70) Linear search is not possible over sorted list

a. Yes Yes! It is possible over sorted and unsorted list

b. No ANS:A

71) In binary search

a. Elements may be in arrange order

b. Elements must be in arrange order c. Elements must not be in arrange order

d. All of the above ANS: B 72) What is the maximum number of comparisons in binary search

a. [Iog2n] + 1

b. [log10n]+1

c. [log2n]+2

d. [log10n]+2 ANS: A

73) For searching a pages from your book , which method is generally used

a. Linear Search

b. Binary Search ANS: B

74) Sorting means

a. Order in first com first serve

b. Order in ascending or descending of values ANS: B 75) The time complexity of Bubble Sort is

a. O

b. O(n2)

c. O(n long n)

d. O(log n) ANS: B

76) Which one is stable sort?

a. Bubble Sort

b. Selection Sort

c. Insertion Sort Correct! Insertion sort is a stable sort because it does not change the relative order of elements with equal keys

d. Quick Sort ANS: C 77) For Heap Sort

a. First create heap then b. First sort then create heap

c. Need not to create heap

d. Just create heap and no required to sort further ANS: A

78) Divide and conquer strategy follows in

a. Quick sort

b. Heap sort

c. Bubble sort

d. Marge sort ANS: D 79) Marge sort continues its division until n elements in the list. The value of n is:

a. 0

b. 1

c. 2

d. 3 ANS: B80) In case of external sorting algorithm

a. Need to check secondary disk access type

b. Need to check primary memory access type

c. None of the above

d. a) and b) both should be checked ANS: C

81) Internal sorting mainly done in

a. Main Memory Correct ! it is done in main memory

b. Secondary Memory ANS: A