C -Set 2

The size of array int a[5]={1,2} is
(A) 4 (B) 12
(C) 10 (D) 6
Ans: C
The size of int array is 2*5=10 bytes as int takes 2 bytes of storage.


The output of the following statements is
char ch[6]={‘e’, ‘n’, ‘d’, ‘\0’, ‘p’};
printf(“%s”, ch);
(A) endp (B) end0p
(C) end (D) error
Ans: C
printf statement will print end because string is terminated at “\0” and in array after d,
we have null character

How many times the following code prints the string “hello”.
for(i=1; i<=1000; i++);
printf(“hello”);
(A) 1 (B) 1000
(C) Zero (D) Syntax error
Ans: A
The “for” loop is terminated by a semicolon so the next statement is execute that is
printing hello.

To declare an array S that holds a 5-character string, you would write
(A) char S[5] (B) String S[5]
(C) char S[6] (D) String S[6]
Ans: A
A string is nothing but a char array.

The function used to read a character from a file that has been opened in read mode is
(A) putc (B) getc
(C) getchar (D) putchar
Ans: B

The function that allocates requested size of bytes and returns a pointer to the first
byte of the allocated space is -
(A) realloc (B) malloc
(C) calloc (D) none of the above
Ans: B
malloc allocates requested size of bytes and returns a pointer to the first byte of the
allocated space.

The constructed datatype of C is known as
(A) Pointers (B) String
(C) Structure (D) Array
Ans: C
Structure is a constructed datatype of C

Which sorting algorithm is the best if the list is already in order?
(A) Quick sort (B) Merge sort
(C) Insertion sort (D) Heap sort
Ans: (C)

The complexity of adding two matrices of order m*n is
(A) m + n (B) mn
(C) max(m, n) (D) min(m, n)
Ans: (B)

Direct or random access of elements is not possible in
(A) Linked list (B) Array
(C) String (D) None of these
Ans: (A)

One can make an exact replica of a Binary Search Tree by traversing it in
(A) Inorder (B) Preorder
(C) Postorder (D) Any order
Ans: (B)

SHARE

About df

    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment