Wednesday, March 05, 2014

Some questions with answers from C Language


Can you write another expression which does the same job as ++*ptr;

Ans: (*ptr++)

Are the expressions *ptr++ and ++*ptr same?

Ans; No. ptr++ increments the pointer and not the value pointed by it, whereas, ++*ptr increments the value being pointed to by ptr.


What is a null pointer, a NULL macro, the ASCII NUL character & null string?

  1. A null pointer is a pointer, which doesn’t point anything.
  2. A NULL macro is used to represent the NULL pointer in source code. It has a value 0 associated with it.        
  3. The ASCII NUL character has all its bits as 0 but doesn’t have any relationship with NULL pointer.
  4. The NULL string is just another name for an empty string.

What will be the output of the following program?

#include<stdio.h>
void junk(int i,int*j)
{
            i=i*i;
            *j=*j**j;
}
void main()
{
            int i=-5,j=-2;
            junk(i,&j);
            printf("\ni=%d, j=%d",i,j);
}


ans: i=-5,j=4


Representation of data structure in memory is known as
  1. Recursive 
  2. Abstract data type
  1. Storage structure
  2. File structure

Which of the following search algorithm requires a sorted array?
  1. Linear search
  2. Hash search 
  3. Binary search
  1. All of these
What will be the output of 5.0 / 2?
  1. 2
  2. 3
  3. 0 
  4.  2.5
In which linked list last node address is null?
  1. Doubly linked list
  2. Circular list 
  3.   Singly linked list
  1. None of the above
The Default Parameter Passing Mechanism is called as
     A.     Call by Value
  1. Call by Reference
  2. Call by Address
  3. Call by Name
In which tree, for every node the height of its left subtree and right subtree differs almost by one?
  1. Binary search tree
     B.     AVL tree
  1. Threaded Binary Tree
  2. Complete Binary Tree
The _______ memory allocation function modifies the previous allocated space.
  1. calloc
  2. free
  3. malloc 
  4.    realloc
Which of the following data structure is linear type?
  1. Strings
  2. Queue
  3. Lists 
  4. All of the above
The statement print f ("%d", 10 ? 0 ? 5 : 1 : 12); will print?
  1. 10
  2. 0
  3. 12 
  4.  1

Recursive functions are executed in a?
  1. First In First Out Order
  2. Load Balancing
  3. Parallel Fashion 
  4. Last In First Out Order

Which operators are known as Ternary Operator?
  1. ::, ?
  2. ?, :
  3. ?, ;;
  4. None of the avobe
An array elements are always stored in _________ memory locations.
    A.     Sequential
  1. Random
  2. Sequential and Random
  3. None of the above
Which of the following shows the correct hierarchy of arithmetic operations in C
  1. / + * -
  2. * - / +
  3. + - / * 
  4.    * / + -

No comments:

Post a Comment