MCQ Set 1 - C

15 Questions | Attempts: 141
Share
SettingsSettings
Please wait...
  • 1/15 Questions

    What is the output of the following 'C' program? main ( ) { printf ('' % f '', sqrt (36.0)); }

    • 6.0
    • 6.000000
    • 6
    • Some absurd result
Please wait...

Quiz Preview

  • 2. 

    What is the output of the following 'C' program? main ( ) { int a [5] = {2, 3}; print f (''\n % d % d % d'', a [2], a [3], a [4]); } 

    • Garbage values

    • 2 3 3

    • 3 2 2

    • 0 0 0

    Correct Answer
    A. 0 0 0
  • 3. 

    What is the output of the following 'C' program? main ( ) { printf (''% d % d % d", sizeof(3.14 f), sizeof (3.14), sizeof (3.14 l)); }

    • 4 4 4

    • 4 Garbage value

    • 4 8 10

    • Error

    Correct Answer
    A. 4 8 10
  • 4. 

    We want to round off x, a float, to an int value. What is the correct way to do so?

    • Y = (int) (x + 0.5);

    • Y = int (x +0.5);

    • Y = (int) x + 0.5;

    • Y = (int (int) x + 0.5;

    Correct Answer
    A. Y = (int) (x + 0.5);
  • 5. 

    By default any real number in 'C' is treated as

    • A float

    • A double

    • A long double

    • Depends upon the memory model that you are using

    Correct Answer
    A. A double
  • 6. 

    What is the output of the following 'C' program? main { printf (''%c'', ''abcdefgh'' [4]);} 

    • Error

    • D

    • E

    • Abcdefgh

    Correct Answer
    A. E
  • 7. 

    In the following 'C' code in which order the functions would be called? a = (f 1 (23, 14) * f 2 (12 / 4) + f 3 ( ));

    • F1, f2, f3

    • F3, f2, f1

    • The order may vary from compiler to compiler

    • None of these

    Correct Answer
    A. F1, f2, f3
  • 8. 

    What is the output of the following 'C' program? main ( ) { int x = 10, y = 10, z = 5, i; i = x <y <z; printf ("\n % d'', i); }

    • 1

    • 0

    • Error

    • 5

    Correct Answer
    A. 1
  • 9. 

    What is the output of the following 'C' program? main ( ) { extern int i; i = 20; print ( "% d'', sizeof(i)); }

    • 2

    • 4

    • Would vary from compiler to compiler

    • Error, i undefined

    Correct Answer
    A. Error, i undefined
  • 10. 

    Consider the following program: main ( ) { int x = 2, y = 5; if (x < y) return (x = x + y); else print f("zl"); print f("z2"); } Then

    • Output is z2

    • Output is z1z2

    • This will result in compilation error

    • None of these

    Correct Answer
    A. None of these
    Explanation
    Return always terminates the function that executed it. main ( ) being a function, will be terminated when it executes the return statement. The return value will be returned to the calling environment, which is the operating system in this case.

    Rate this question:

  • 11. 

    Which header file should you include if you are to develop a function that can accept variable number of arguments?

    • Vararg. h

    • Stadlib. h

    • Stdio. h

    • Stdarg. h

    Correct Answer
    A. Stdarg. h
  • 12. 

    What is the output of the following 'C' program? main ( ) { int i = 2; print f (''\n % d % d'', + + i, + + i); } 

    • 3 4

    • 4 3

    • 4 4

    • Output may vary from compiler to compiler

    Correct Answer
    A. Output may vary from compiler to compiler
  • 13. 

    What is the output of the following 'C' program? main { Float a = 0. 7; if (a < 0.7) print f (''C''); else print f ('' C + + ''); }

    • C

    • C++

    • Error

    • None of the above

    Correct Answer
    A. Error
  • 14. 

    What is the output of the following 'C' program? main ( ) { char str [7] = ''strings''; print ('' % c ''; str); }

    • Error

    • Strings

    • Cannot predict

    • None of these

    Correct Answer
    A. Cannot predict
  • 15. 

    The following program main ( ) { static int a { } = {7, 8, 9}; print f("%d", a {2} = 2 [a] + A [2]; }

    • Results in bus error

    • Results in segmentation violation error

    • Will not compile successfully

    • None of these

    Correct Answer
    A. None of these
    Explanation
    a [2] will be converted to * (a + 2)
    * (a + 2) can sas well be written as * (2 + a)
    * (2 + a) is nothing but 2 [a]. So, a [2] is sam eas 2 [a], which is same as * (2 + a). So, it prints 9 + 9 = 18

    Rate this question:

Quiz Review Timeline (Updated): Mar 20, 2022 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 20, 2022
    Quiz Edited by
    ProProfs Editorial Team
  • Jul 29, 2010
    Quiz Created by
    Satyajitclasses
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.