Quiz on C++ Functions

Last Updated :
Discuss
Comments

Question 1

What is the scope of a local variable?

  • Entire program

  • Function or block

  • File

  • Class

Question 2

What does the static keyword do in a function?

  • Makes the variable global

  • Preserves value between calls

  • Allocates dynamic memory

  • Makes it constant

Question 3

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

  • main()

  • class()

  • loop()

  • variable()

Question 4

What is the lifetime of a global variable?

  • Function duration

  • Block duration

  • Program duration

  • Loop duration

Question 5

What is a function in C++?

  • A data type

  • A reusable block of code

  • A variable

  • A loop

There are 5 questions to complete.

Take a part in the ongoing discussion