Section D: Basic Programming

15 Questions | Total Attempts: 125

SettingsSettingsSettings
Please wait...
Programming Quizzes & Trivia

Questions and Answers
  • 1. 
    If you could find the (n/4)th element of an array in O(n) time, then what is the worst time complexity of quick sort algorithm. (If this algorithm is used to decide the pivot element.)
    • A. 

      O(logn)

    • B. 

      O(nlogn)

    • C. 

      O(2n)

    • D. 

      None of these

  • 2. 
    Find the minimum number of comparisons required to find both the max and min elements of an array containing 20 elements.
    • A. 

      28

    • B. 

      20

    • C. 

      21

    • D. 

      19

  • 3. 
    Find the value of counter in the end:  int counter=0; for(i=0;i<10;i++)   for(j=i+1;j<10;j++)     for(k=j+1;k<10;k++)       for(l=k+1;l<10;l++)         for(m=l+1;m<10;m++)           counter++;  
    • A. 

      10C4

    • B. 

      11C5

    • C. 

      12C6

    • D. 

      10C5

    • E. 

      11C4

  • 4. 
    Consider a set S of the first 10 natural numbers. Find the number of subsets that do not contain consecutive elements.
    • A. 

      10

    • B. 

      55

    • C. 

      121

    • D. 

      144

    • E. 

      157

  • 5. 
    A disk contains 16 partition unit , each unit contains 128 subunits, and each subunit contains 256 sectors of 512 byte each. Find out what is total storage capacity? Also find out the no of bits required to identify each sector?
    • A. 

      256 MB, 11 bits

    • B. 

      256 MB, 19 bits

    • C. 

      512 MB, 19 bits

    • D. 

      1024 MB, 12 bits

  • 6. 
    Given an sorted array, what is the complexity of finding weather a number is present n/2 times or not?
    • A. 

      O(lgn)

    • B. 

      O(n)

    • C. 

      O((lgn)^2)

    • D. 

      O(1)

    • E. 

      O(0)

  • 7. 
    How many instances of an abstract class can be created?
    • A. 

      5

    • B. 

      0

    • C. 

      13

    • D. 

      1

    • E. 

      None of these

  • 8. 
    Which of the following function prototype is perfectly acceptable?
    • A. 

      Int Function(int Tmp = Show());

    • B. 

      Float Function(int Tmp = Show(int, float));

    • C. 

      Float = Show(int, float) Function(Tmp);

    • D. 

      None of These

  • 9. 
    What is the output of this program? #include<stdio.h>   int main() {     union var     {         int a, b;     };     union var v;     v.a=10;     v.b=20;     printf("%d\n", v.a);     return 0; }
    • A. 

      10

    • B. 

      20

    • C. 

      30

    • D. 

      0

    • E. 

      15

  • 10. 
    What is the output of this program? #include<stdio.h>   int main() {     struct value     {         int bit1:1;         int bit3:4;         int bit4:4;     }bit={1, 2, 13};       printf("%d, %d, %d\n", bit.bit1, bit.bit3, bit.bit4);     return 0; }
    • A. 

      1, 2, 13

    • B. 

      1, 4, 4

    • C. 

      -1, 2, -3

    • D. 

      -1, -2, -13

    • E. 

      None of These

  • 11. 
    What is the output of this program on an implementation where int occupies 2 bytes? #include    int main(void) {    int i = 3;    int j;      j = sizeof(++i + ++i);      printf("i=%d j=%d\n", i, j);      return 0; }  
    • A. 

      I=4 j=2

    • B. 

      I=3 j=2

    • C. 

      I=5 j=2

    • D. 

      The behavior is undefined

  • 12. 
    What will be the output of the program in 16 bit platform (Turbo C under DOS)? #include<stdio.h>   int main() {     struct value     {         int bit1:1;         int bit3:4;         int bit4:4;     }bit;     printf("%d\n", sizeof(bit));     return 0; }
    • A. 

      1

    • B. 

      2

    • C. 

      4

    • D. 

      9

    • E. 

      3

  • 13. 
    What is the type of tmp?
    • A. 

      Function taking two pointer-to-float arguments and returning pointer to int

    • B. 

      Pointer to int

    • C. 

      Pointer to function taking two pointer-to-float arguments and returning int

    • D. 

      None of the above

  • 14. 
    What is the output of this program? #include<stdio.h> int main() {     enum days {MON=-1, TUE, WED=6, THU, FRI, SAT};     printf("%d, %d, %d, %d, %d, %d\n", MON, TUE, WED, THU, FRI, SAT);     return 0; }
    • A. 

      -1, 0, 1, 2, 3, 4

    • B. 

      -1, 2, 6, 3, 4, 5

    • C. 

      -1, 0, 6, 2, 3, 4

    • D. 

      -1, 0, 6, 7, 8, 9

    • E. 

      None of These

  • 15. 
    Point out the error in the following program:  #include   union emp {     int empno;     int age; };   int main() {     union emp e = {10, 25};     printf("%d %d", e.empno, e.age);     return 0; }
    • A. 

      Error: Lvalue required

    • B. 

      Error: Rvalue required

    • C. 

      Error: cannot initialize more than one union member

    • D. 

      No Error

    • E. 

      Error: Incorrect code

Back to Top Back to top