Save
Upgrade to remove ads
Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
focusNode
Didn't know it?
click below
 
Knew it?
click below
Don't Know
Remaining cards (0)
Know
0:00
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

Stack #4001948

QuestionAnswer
TRUE OR FALSE. The program that calls a function is often referred to as the calling program. True
The number of actual arguments must be _________ as the number of formal parameters. equal
Which is NOT an essential feature of a proper recursive function? Not permitted to do any I/O
TRUE OR FALSE. The only difference between the header and the prototype is the colon. False
TRUE OR FALSE. Formal parameters are variables used within the function header that receives a copy of the actual argument values. TRUE
A segment that groups a number of program statements to perform specific task function
It provides one-way communication of data from the calling program to the function. pass by value
A function that can be made to return a single value to the calling program. non-void
How many minimum number of functions are needed to be presented in C++? 1
Here is a function, double numbers (int x), what is the name of this function? numbers
Which of the following is used to terminate the function prototype? ;
TRUE OR FALSE. If the function returns a value then the return_type must be void. FALSE
If we have a function int stop (int n) , can we send it a different variable in the main program? For example, stop (x) Yes
Recursion is a method in which the solution of a problem depends on ____________ Smaller instances of the same problem
TRUE OR FALSE. Recursion can be more difficult to debug compared to an equivalent iterative program. TRUE
Consider the following code snippet: void my_recursive_function() { my_recursive_function(); } int main() { my_recursive_function(); return 0; } What will happen when the above snippet is executed? The code will run for some time and stop when the stack overflows
TRUE OR FALSE. A recursive program cannot call itself always, or it would never stop at some point, the routine encounters a subtask that it can perform without calling itself. This case is called the recursive case. False
If a variable is declared outside a function and can be used by other functions, what kind of variable is this? global variable
What’s the output of the calling something(4);? int something(int number) { if(number <= 0) return 1; else return number * something(number-1); } 24
The variable that receives a copy of the value passed by the actual argument in the program is ________. a
What is the value returned by the recursive function if the base condition is met? recursion1.PNG 1
When flow of control is transferred to the calling program, program execution resumes on the next statement after the function call
Which of the following statements is true? Recursion uses more memory compared to iteration
TRUE OF FALSE. Only predefined functions can be involved in recursion. FALSE
What is the output of the following code? void my_recursive_function(int n) { if(n == 0) return; cout<<n; my_recursive_function(n-1); } int main() { my_recursive_function(10); return 0; } 10 9 8...1
TRUE OR FALSE. The case in which the routine calls itself to perform a subtask, is called as base case. FALSE
Given the following code: int func(int a, int b){ if(b==0) return 0; if(b==1) return a; return a + func(a,b-1); } what will be the output of func(3,8) . 24
How many times is the recursive function called, when the following code is executed? void my_recursive_function(int n) { if(n == 0) return; cout<<n; my_recursive_function(n-1); } int main() { my_recursive_function(10); return 0; } 11
Recursion is similar to which of the following? loop
Which data structure is used to perform recursion? stack
What is the output of the program? Consider the following recursive function fun(x, y). What is the value of fun(4, 3) int fun(int x, int y) { if (x == 0) return y; return fun(x - 1, x + y); } 13
Say we have a function, double subtract (double x, double y), what is the correct way to call this function in the main program? subtract (x,y);
By default how the value are passed in C++? call by value
TRUE OR FALSE. The correspondence between actual and formal parameter is one-to-one basis according to the respective orders. True
What will happen while using pass by reference? The location of variable in memory is passed to the function so that it can use the same memory area for its processing
TRUE OR FALSE. A recursive routine performs a task in part by calling itself to perform the subtasks. TRUE
Which of the following problems can be solved using recursion? i. Factorial of a number ii. Nth Fibonacci number iii. Length of a string i,ii,iii
TRUE OR FALSE. Any routine that calls itself is recursive TRUE
Recursion itself cannot be used as a replacement to iteration or looping False
What will be the output of the following code? int cnt=0; void my_recursive_function(int n) { if(n == 0) return; cnt++; my_recursive_function(n/10); } FORMATIVE 7 TN03 int main() { my_recursive_function(123456789); cout<<cnt; return 0; } 9
Which of the following problems can’t be solved using recursion? Problems without base case
It consists of data type, name of the function and parameter listing. function header
Which of the following is important in a function? Both return type and function name
Here is a function, double numbers (int x), what data type will this function return? Double
TRUE OR FALSE. Any problem that can be solved recursively cannot also be solved iteratively. FALSE
What’s happen if the base condition is not defined in recursion? Stack Overflow
TRUE OR FALSE. A branching structure is the main control structure in a recursive routine while a looping structure is the main control structure in an iterative routine. TRUE
Where does the return statement returns the execution of the program? calling function
Where should the prototype be? before int main()
Which of the following statements is not correct? When the function cube() was called, the argument used is passed by reference.
What is the scope of the global variable declared outside the user defined function and after the preprocessor directive? Whole program
Consider this piece of code: void mysterious(int i, int &k) { i = 1; k = 2; } int main () { int x = 0; FORMATIVE 7 TN03 mysterious (x, x); cout << x << endl; return 0; } 2
What are mandatory parts in function declaration? return type,function name
TRUE OR FALSE. All the recursive calls are pushed onto the stack TRUE
void print(int n) { if (n == 0) return; cout<<n%2; cout<<n/2; } What will be the output of print(12)? 0011
What does the following recursive code do? void my_recursive_function(int n) { if(n == 0) return; FORMATIVE 7 TN03 my_recursive_function(n-1); cout<<n; } int main() { my_recursive_function(10); return 0; } Prints the numbers from 1 to 10
_______________ is a powerful technique which is used to invoke a function. Recursion
TRUE OR FALSE. Recursion makes our code shorter and cleaner. TRUE
TRUE OR FALSE. The recursive routine always contains a selection statement-either an "if" or a "switch". TRUE
Running out of memory may occur due to ______ recursive function call
TRUE OR FAlSE. function is a self contained block of code with a specific purpose. TRUE
This symbol specifies that the corresponding arguments in the function are to be passed by reference. &
Here is a function, double numbers (int x), what data type will this function take in? int
TRUE OR FALSE. Function prototype provides the basic information about a function which tells the compiler that the function is used correctly or not. True
TRUE OR FALSE. Recursion takes more memory allocation due to the stack operation of all the function calls. TRUE
What’s the output of the following code? int doSomething(int a, int b) { if (b==1) return a; else return a + doSomething(a,b-1); } doSomething(2,3); 6
What is the scope of the variable declared in the user defined function? only inside the { } block
What is the main function's default return type? int
TRUE OR FALSE. A function that can be made to return a single value to the calling program is referred to as void function. FALSE
TRUE OR FALSE. Recursion is required in problems concerning advanced algorithms such as Graph and Tree Traversal. TRUE
What’s the output of the following code? int rec(int num){ return (num) ? num%10 + rec(num/10):0; FORMATIVE 7 TN03 } int main(){ cout<<rec(4567); } 22
TRUE OR FALSE. Recursion performs faster while executing the iteration process. FALSE
The following are problems that often have simple recursive solutions except ________. display an output
TRUE OR FALSE. Function prototype contains different information as the function header contains. FALSE
int my_function (double a), what type of data will this functions take in? DOUBLE
If a variable is declared inside a function, what kind of variable is this? local variable
In recursion, the condition for which the function will stop calling itself is ____________ base case
TRUE OR FALSE. When a recursive function is executed, the recursive calls are implemented instantly. FALSE
Where does the execution of the program starts? main() function
What will be the output of the following C++ code? #include <iostream> using namespace std; int fun(int=0, int = 0); int main() { cout << fun(5); return 0; } int fun(int x, int y) { return (x+y); } 5
What does the following function print for n = 25? void fun(int n) { if (n == 0) return; cout<<n%2; fun(n/2); } 10011
int sum(int n) { if (n==0) return n; else return n + sum(n-1); } 36
From which function the execution of a C++ program starts? main() function
#include <iostream> using namespace std; void greet() { cout<<"Hi Jayar"; } int main() { greet(); return 0; } HI JAYAR
What will be the output of the following C++ code? #include<iostream> using namespace std; int fun(int x = 0, int y = 0, int z=0) { return (x + y + z); } int main() { cout << fun(1,2,3); return 0; } 6
Which of the following statement is correct? All the parameters of a function can be default parameters.
Which is more effective while calling the functions? call by reference
When using a function, what is the first thing you must do? prototype
Which of the following is the default return value of functions in C++? int
What is the output of this program? #include < iostream > using namespace std; void mani() void mani() { cout << "hai"; } int main() { main(); return 0; } there is an error
Created by: user-1768430
 

 



Voices

Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
Retries:
restart all cards