M1 User-Defined Functions Flashcards

(53 cards)

1
Q

Which of the following function gets the floor of a number?

Group of answer choices

= floor

= Floors

= flooring

= floors

A

= floor

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

Which of the following is NOT a built-in function?
Group of answer choices

= getScore()

= pow()

= sqrt()

= abs()

A

= getScore()

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

In C++, from which function the execution of a C++programs starts?
Group of answer choices

= new() function

= start() function

= main() function

= end() function

A

= main() function

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

A function can be called from another function using its ____________.

Group of answer choices

= return type

= name

= variables

= comment

A

= name

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

What will you use if you do NOT intended to return value?

Group of answer choices

= void

= const

= static

= int

A

= void

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

A type of variable inside a function.

Group of answer choices

= Foreign

= Global

= Constant

= Local

A

= Local

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

Two or more functions having the same name but different argument(s) are known as:
Group of answer choices

= recursive function

= main function

= void function

= overloaded function

A

= overloaded function

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

When do we define the default values for a function?

Group of answer choices

= When a function is called

= When a function is planned

= When a function is declared

= When the scope of the function is over

A

= When a function is declared

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

include<iostream></iostream>

What is the output of the following code?

using namespace std;

int fun(int x = 0, int y = 0, int z)

{

return (x + y + z);

}

int main()

{

cout &laquo_space;fun(10);

return 0;

}

Group of answer choices

= Error

= 20

= 10

= 0

A

= Error

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

An overloaded function must have:
Group of answer choices

= Different return types

= Different types and/or number of arguments

= Different executable statements

= All of the mentioned

A

= Different types and/or number of arguments

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

What are the advantages of passing arguments by reference?
Group of answer choices

= Changes to parameter values within the function also affects the original arguments

= Less memory is used

= All of the mentioned

= There is need to copy parameter values

A

= Changes to parameter values within the function also affects the original arguments

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

When two functions with the same name are defined in the same scope, the function is:
Group of answer choices

= Overloaded

= Final

= Static

= Double

A

= Overloaded

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

In order to return a value from a function you must use:
Group of answer choices

= overload

= return

= parameter

= void

A

= return

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

What is the default argument of b in the function?

int sum(int a=10, int b, int c=30);

Group of answer choices

= 20

= error

= 10

= 0

A

= 20

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

How many parameters are there in the function: int add(int a,int b)?
Group of answer choices

= 2

= 4

= 3

= 1

A

= 2

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

Which of the following is NOT a proper function prototype (definition)?
Group of answer choices

= char x();

= int funct (char x, char y) ;

= double func(char x)

= void funct();

A

= double func(char x)

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

To execute the codes of function, the user-defined function needs to be __________.
Group of answer choices

= debugged

= defined

= invoked

= saved

A

= invoked

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

In C++, which of the following is TRUE?
Group of answer choices

= Functions can have no argument and no value

= All of the mentioned

= Function can have no argument but return value

= Function can have no argument but no return value

A

= All of the mentioned

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

In C++, the block of code begins and ends with:
Group of answer choices

= []

= <>

= ()

= {}

A

= {}

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

What is the return type of the function with the prototype :

int functionx (char x, char y) ;

Group of answer choices

= double

= int

= char

= boolean

A

= int

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

The function that returns no value is known as
Group of answer choices

= private function

= static

= void function

= null

A

= void function

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

It states that the function is a non-returning value function
Group of answer choices

= int

= voided

= void

= double

23
Q

In order to define the absolute value of a number we should use:
Group of answer choices

= absol

= abz

= Absolute

= abs

24
Q

Which of the following computes for the absolute value for int?
Group of answer choices

= absol

= abs

= fabs

= labs

25
In a program you saw the following: int myFunctionTools(int x) float myFunctionTools(float x) double myFunctionTools(double x, double y) What‘s the best description of the given functions? Group of answer choices = Functions are overloaded = Functions have different parameter list = Functions have different returning value = Functions have no default values
= Functions have no default values
26
Which of the following returns an integer? Group of answer choices = void myInitialGrade(int x) = int myRoundedGrade(int x) = double myAverageGrade(double x) = void myFinalGrade(int x, int y)
= int myRoundedGrade(int x)
27
If the user didn’t supply a value in a function, then what value will it take? Group of answer choices = none of the mentioned = default value = 0 = rise an error
= default value
28
Where should default parameters appear in a function prototype? Group of answer choices = Middle of the parameter list = To the rightmost side of the parameter list = Anywhere inside the parameter list = To the leftmost side of the parameter list
= To the leftmost side of the parameter list
29
What is the output of the program? #include < iostream > using namespace std; void fun(int x, int y) { x = 20; y = 10; } int main() { int x = 10; fun(x, x); cout << x; return 0; } Group of answer choices = 30 = 10 = error = 20
= 10
30
What would be the output of the given program? #include using namespace std; int factorial(int); int main() { int n = 4; cout << "Factorial is = " << factorial(4); return 0; } int factorial(int n) { if (n > 1) { return n*factorial(n-1); } else { return 1; } } Group of answer choices = Factorial is = 16 = Factorial is = 24 = Factorial is = 12 = Factorial is = 4
= Factorial is = 24
31
What are the mandatory parts of a function declaration? Group of answer choices = None of mentioned = Return type, function name and parameters = Parameter = Return type and function name
= Return type and function name
32
When will we use the function overloading? Group of answer choices = Different function name but same number of arguments = Same function name but same number of arguments = Same function name but different number of arguments = Different function name but different number of arguments
= Same function name but different number of arguments
33
An overloaded function must have: Group of answer choices = Different executable statements = Different types and/or number of arguments = Different return types = All of the mentioned
= Different types and/or number of arguments
34
A function that calls itself is a __________ function Group of answer choices = main = void = recursive = overloaded
= recursive
35
Which of the following is NOT a proper function prototype (definition)? Group of answer choices = char letter(); = int secondfunct (char x, char y) ; = func(int x) = void funct();
= func(int x)
36
Which of the following is a complete function? Group of answer choices = void functCall(int) {cout<< “Hello”} = int functCall (int x) {return x = x+1;} = int functCall(); = void funcCall(x) {cout<<”Hello”}
= int functCall (intx) {return x=x+1}
37
Check the given code: int add(int a,int b) { int add; add = a + b; return add; } What would be the returning value data type? Group of answer choices = boolean = int = double = long
- int
38
Complete the code: #include using namespace std; // Print grade for the score _______ printGrade(double score) { if (score >= 90.0) cout << 'A'; else if (score >= 80.0) cout << 'B'; else if (score >= 70.0) cout << 'C'; else if (score >= 60.0) cout << 'D'; else cout << 'F'; } int main() { cout << "Enter a score: "; double score; cin >> score; cout << "The grade is "; printGrade(score); return 0; } Group of answer choices = double = void = char = int
= void
39
What is the return value of the following function: double myRewards(double x, double y)? Group of answer choices = float = long = double = int
= double
40
What is the default argument of b in the function? int sum(int a, int b=10, int c=20); Group of answer choices =10 = 0 = error = 20
= 10
41
In a program you saw the following: int myFunctionTools(int x) float myFunctionTools(float x) double myFunctionTools(double x, double y) What‘s the best description of the given functions? Group of answer choices = Functions have no default values = Functions have different parameter list = Functions have different returning value = Functions are overloaded
= Functions are overloaded
42
Overloaded functions are: Group of answer choices = Very long functions that can hardly run = None of the mentioned = One function containing another one or more functions inside it = Two or more functions with the same name but different number of parameters or type
= Two ore more functions with the same name but different number of parameters or type
43
Which of the following returns an integer? Group of answer choices double myAverageGrade(double x) = int myRoundedGrade(int x) = void myFinalGrade(int x, int y) = void myInitialGrade(int x)
= int myRoundedGrade(int x)
44
It refers to the information that can be passed to a function Group of answer choices = Variable = Parameter = Statement = Syntax
= Parameter
45
How many minimum numbers of functions need to be present in a C++ program? Group of answer choices = 1 = 0 = 2 = 3
= 1
46
Which of the following computes for the square root of a number? Group of answer choices = square = abs = srand = sqrt
= sqrt
47
Which of the following computes for the power of a given number? Group of answer choices = floor = pow = power = fabs
= pow
48
Library functions are also known as _______ function: Group of answer choices = Built-in = User defined = void = main
= Built-in
49
How many parameters are there in the function: int theArea(int a,int b, int c)? Group of answer choices = 4 = 1 = 3 = 2
= 3
50
Which of the following function is used to accept user inputs? Group of answer choices = return = round = cin = cout
= cin
51
What is a default return type of a function? Group of answer choices = char = double = int = void
= int
52
What is the output for the given program? #include using namespace std; void f1() { cout <<1;} int main() { f1(); goto x; cout << "hello"; x: cout << "hi"; return 0;} Group of answer choices = 1hi = hi hello 1 =1 hello = 1 hello hi
= 1hi
53