Online Test for C

  1. perror( ) function used to ?
    Work same as printf()
    prints the error message specified by the compiler
    prints the garbage value assigned by the compiler
    None of the above

  1. The largest element of an array index is called its
    Lower bound
    Upper bound
    Range
    All of the above


  1. A zero value is considered to be false and a non-zero value is considered to be true.
    True
    False

  1. Which one of the following in-place sorting algorithms needs the minimum number of swaps?
    Insertion Sort
    Quick Sort
    Heap Sort
    Selection Sort

  1. Find Error/Output in follwing code:
  2.                                 
    int main() {
    
      int x = 0, y = 0;
      if(x > 0)
        if(y > 0)
          printf("True"); 
      else
        printf("False"); 
    }
    No Output
    True
    False
    Error because of dangling else problem


  1. Which of the following has compilation error in C?
    int n = 32;
    char ch = 65;
    float f = (float) 3.2;
    None of the above

  1. Find Error/Output in follwing code:
  2.                                 
    void fn() {
    
     int a = 10;
     static int b = 20;
     printf("a = %d b = %d", ++a, ++b);

    int main() {
     fn();
     fn();
     return 0;
    }
    a = 11 b = 21 a = 11 b = 22
    a = 11 b = 21 a = 11 b = 22
    a = 11 b = 21 a = 11 b = 22
    a = 11 b = 21 a = 11 b = 22

  1. Find Error/Output in follwing code:
  2.                                 
    int main()
    
    {
      int x = 7538;
      printf("%d %dn", x % 100, x / 10);
    }
    38 753
    75 538
    538 38
    0 753

  1. Which of the following sorting algorithms does NOT have a worst-case running time of O(n2)?
    Insertion sort
    Merge sort
    Quicksort
    Bubble sort

Post Your Question
Social Sharing
Search