M1 User-Defined Functions Flashcards

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

A

= void

23
Q

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

= absol

= abz

= Absolute

= abs

A

= abs

24
Q

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

= absol

= abs

= fabs

= labs

A

= abs

25
Q

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

A

= Functions have no default values

26
Q

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)

A

= int myRoundedGrade(int x)

27
Q

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

A

= default value

28
Q

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

A

= To the leftmost side of the parameter list

29
Q

include < iostream >

What is the output of the program?

using namespace std;

void fun(int x, int y)

{

x = 20;

y = 10;

}

int main()

{

int x = 10;

fun(x, x);

cout &laquo_space;x;

return 0;

}

Group of answer choices

= 30

= 10

= error

= 20

A

= 10

30
Q

include <iostream></iostream>

What would be the output of the given program?

using namespace std;
int factorial(int);
int main()
{
int n = 4;
cout &laquo_space;“Factorial is = “ &laquo_space;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

A

= Factorial is = 24

31
Q

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

A

= Return type and function name

32
Q

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

A

= Same function name but different number of arguments

33
Q

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

A

= Different types and/or number of arguments

34
Q

A function that calls itself is a __________ function
Group of answer choices

= main

= void

= recursive

= overloaded

A

= recursive

35
Q

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();

A

= func(int x)

36
Q

Which of the following is a complete function?
Group of answer choices

= void functCall(int) {cout&laquo_space;“Hello”}

= int functCall (int x) {return x = x+1;}

= int functCall();

= void funcCall(x) {cout«”Hello”}

A

= int functCall (intx) {return x=x+1}

37
Q

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

A
  • int
38
Q

include <iostream></iostream>

Complete the code:

using namespace std;

// Print grade for the score
_______ printGrade(double score)
{
if (score >= 90.0)
cout &laquo_space;‘A’;
else if (score >= 80.0)
cout &laquo_space;‘B’;
else if (score >= 70.0)
cout &laquo_space;‘C’;
else if (score >= 60.0)
cout &laquo_space;‘D’;
else
cout &laquo_space;‘F’;
}

int main()
{
cout &laquo_space;“Enter a score: “;
double score;
cin&raquo_space; score;

cout &laquo_space;“The grade is “;
printGrade(score);

return 0;
}

Group of answer choices

= double

= void

= char

= int

A

= void

39
Q

What is the return value of the following function: double myRewards(double x, double y)?
Group of answer choices

= float

= long

= double

= int

A

= double

40
Q

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

A

= 10

41
Q

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

A

= Functions are overloaded

42
Q

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

A

= Two ore more functions with the same name but different number of parameters or type

43
Q

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)

A

= int myRoundedGrade(int x)

44
Q

It refers to the information that can be passed to a function
Group of answer choices

= Variable

= Parameter

= Statement

= Syntax

A

= Parameter

45
Q

How many minimum numbers of functions need to be present in a C++ program?
Group of answer choices

= 1

= 0

= 2

= 3

A

= 1

46
Q

Which of the following computes for the square root of a number?
Group of answer choices

= square

= abs

= srand

= sqrt

A

= sqrt

47
Q

Which of the following computes for the power of a given number?
Group of answer choices

= floor

= pow

= power

= fabs

A

= pow

48
Q

Library functions are also known as _______ function:
Group of answer choices

= Built-in

= User defined

= void

= main

A

= Built-in

49
Q

How many parameters are there in the function:

int theArea(int a,int b, int c)?

Group of answer choices

= 4

= 1

= 3

= 2

A

= 3

50
Q

Which of the following function is used to accept user inputs?
Group of answer choices

= return

= round

= cin

= cout

A

= cin

51
Q

What is a default return type of a function?
Group of answer choices

= char

= double

= int

= void

A

= int

52
Q

include <iostream></iostream>

What is the output for the given program?

using namespace std;
void f1()
{
cout «1;}
int main()
{
f1();
goto x;
cout &laquo_space;“hello”;
x: cout &laquo_space;“hi”;
return 0;}

Group of answer choices

= 1hi

= hi hello 1

=1 hello

= 1 hello hi

A

= 1hi

53
Q
A