Quiz on C++ Functions

Last Updated :
Discuss
Comments

Question 1

What is a function in C++?

  • A

    A data type

  • B

    A reusable block of code

  • C

    A variable

  • D

    A loop

Question 2

What is the scope of a local variable?

  • A

    Entire program

  • B

    Function or block

  • C

    File

  • D

    Class

Question 3

What does the static keyword do in a function?

  • A

    Makes the variable global

  • B

    Preserves value between calls

  • C

    Allocates dynamic memory

  • D

    Makes it constant

Question 4

Which function is typically executed first when a program begins execution?

  • A

    main()

  • B

    class()

  • C

    loop()

  • D

    variable()

Question 5

What is the lifetime of a global variable?

  • A

    Function duration

  • B

    Block duration

  • C

    Program duration

  • D

    Loop duration

There are 5 questions to complete.

Take a part in the ongoing discussion