Search Header Logo

chapter 5 Basic Concepts of Function in C++

Authored by MAHANI BINTI ZAKARIA (POLIMAS)

Information Technology (IT)

University

Used 10+ times

chapter 5 Basic Concepts of Function in C++
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the main purpose of using functions in a C++ program?

To increase the size of the program

To slow down the execution

To divide the program into smaller parts

To reduce readability

Answer explanation

Functions help organize code into smaller blocks that are easier to manage and reuse.

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which keyword is used to define a function in C++?

define

void

function

return

Answer explanation

The keyword void is used when a function does not return a value. It is part of the function definition.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How many times can a function be called in a C++ program?

Only once

Twice

As many times as needed

Never

Answer explanation

Functions can be called repeatedly to perform a task, which helps avoid writing the same code again

4.

MULTIPLE CHOICE QUESTION

1 min • 2 pts

Media Image

What will be the output of this code?

Hello!

Hello!Hello!

Error

Nothing

Answer explanation

Media Image

The function greet() is called twice, so "Hello!" will be printed two times.

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which part of the function defines the data type of the returned value?

Function body

Function name

Return type

Parameters

Answer explanation

The return type (e.g., int, void, float) defines what kind of value the function will return.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?