Functions Flashcards

1
Q

Why do we use functions

A

To perform tasks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Advantages of using functions

A
  1. Code reusability

2. Code optimization.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How are functions (code reusable)

A

When you create a function in C++, you can call it many times. So we don’t need to write the same code again and again.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do functions optimize code

A

We don’t need to write much code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the two categories of functions

A
  1. Library functions

2. User- defined functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are library functions

A

these are functions declared in the C++ header files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are user defined functions ?

A

These are functions created by the C++ programmer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the syntax of creating a function

A
return_type function_name(datatype parameter) 
{
// code to be executed
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the two ways to pass value or data to a function ?

A
  1. Call by value

2. Call by reference.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is call by value

A

In call by value the original value is not modified

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is call by reference

A

In call by reference the original value is modified because we pass reference (address)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Differences between call by value and call by reference

A

in call by value changes made inside the function is not reflected on other functions.

Whereby in call by reference changes made inside the function is reflected outside the function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a recursion function ?

A

This is when a function is called within the same function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly