M1 User-Defined Functions Flashcards
Which of the following function gets the floor of a number?
Group of answer choices
= floor
= Floors
= flooring
= floors
= floor
Which of the following is NOT a built-in function?
Group of answer choices
= getScore()
= pow()
= sqrt()
= abs()
= getScore()
In C++, from which function the execution of a C++programs starts?
Group of answer choices
= new() function
= start() function
= main() function
= end() function
= main() function
A function can be called from another function using its ____________.
Group of answer choices
= return type
= name
= variables
= comment
= name
What will you use if you do NOT intended to return value?
Group of answer choices
= void
= const
= static
= int
= void
A type of variable inside a function.
Group of answer choices
= Foreign
= Global
= Constant
= Local
= Local
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
= overloaded function
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
= When a function is declared
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 «_space;fun(10);
return 0;
}
Group of answer choices
= Error
= 20
= 10
= 0
= Error
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
= Different types and/or number of arguments
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
= Changes to parameter values within the function also affects the original arguments
When two functions with the same name are defined in the same scope, the function is:
Group of answer choices
= Overloaded
= Final
= Static
= Double
= Overloaded
In order to return a value from a function you must use:
Group of answer choices
= overload
= return
= parameter
= void
= return
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
= 20
How many parameters are there in the function: int add(int a,int b)?
Group of answer choices
= 2
= 4
= 3
= 1
= 2
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();
= double func(char x)
To execute the codes of function, the user-defined function needs to be __________.
Group of answer choices
= debugged
= defined
= invoked
= saved
= invoked
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
= All of the mentioned
In C++, the block of code begins and ends with:
Group of answer choices
= []
= <>
= ()
= {}
= {}
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
= int
The function that returns no value is known as
Group of answer choices
= private function
= static
= void function
= null
= void function
It states that the function is a non-returning value function
Group of answer choices
= int
= voided
= void
= double
= void
In order to define the absolute value of a number we should use:
Group of answer choices
= absol
= abz
= Absolute
= abs
= abs
Which of the following computes for the absolute value for int?
Group of answer choices
= absol
= abs
= fabs
= labs
= abs
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
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)
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
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
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 «_space;x;
return 0;
}
Group of answer choices
= 30
= 10
= error
= 20
= 10
include <iostream></iostream>
What would be the output of the given program?
using namespace std;
int factorial(int);
int main()
{
int n = 4;
cout «_space;“Factorial is = “ «_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
= Factorial is = 24
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
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
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
A function that calls itself is a __________ function
Group of answer choices
= main
= void
= recursive
= overloaded
= recursive
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)
Which of the following is a complete function?
Group of answer choices
= void functCall(int) {cout«_space;“Hello”}
= int functCall (int x) {return x = x+1;}
= int functCall();
= void funcCall(x) {cout«”Hello”}
= int functCall (intx) {return x=x+1}
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
include <iostream></iostream>
Complete the code:
using namespace std;
// Print grade for the score
_______ printGrade(double score)
{
if (score >= 90.0)
cout «_space;‘A’;
else if (score >= 80.0)
cout «_space;‘B’;
else if (score >= 70.0)
cout «_space;‘C’;
else if (score >= 60.0)
cout «_space;‘D’;
else
cout «_space;‘F’;
}
int main()
{
cout «_space;“Enter a score: “;
double score;
cin»_space; score;
cout «_space;“The grade is “;
printGrade(score);
return 0;
}
Group of answer choices
= double
= void
= char
= int
= void
What is the return value of the following function: double myRewards(double x, double y)?
Group of answer choices
= float
= long
= double
= int
= double
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
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
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
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)
It refers to the information that can be passed to a function
Group of answer choices
= Variable
= Parameter
= Statement
= Syntax
= Parameter
How many minimum numbers of functions need to be present in a C++ program?
Group of answer choices
= 1
= 0
= 2
= 3
= 1
Which of the following computes for the square root of a number?
Group of answer choices
= square
= abs
= srand
= sqrt
= sqrt
Which of the following computes for the power of a given number?
Group of answer choices
= floor
= pow
= power
= fabs
= pow
Library functions are also known as _______ function:
Group of answer choices
= Built-in
= User defined
= void
= main
= Built-in
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
Which of the following function is used to accept user inputs?
Group of answer choices
= return
= round
= cin
= cout
= cin
What is a default return type of a function?
Group of answer choices
= char
= double
= int
= void
= int
include <iostream></iostream>
What is the output for the given program?
using namespace std;
void f1()
{
cout «1;}
int main()
{
f1();
goto x;
cout «_space;“hello”;
x: cout «_space;“hi”;
return 0;}
Group of answer choices
= 1hi
= hi hello 1
=1 hello
= 1 hello hi
= 1hi