Been very busy with my job. I have very little time in my day recently and it's causing a strain on my school.
If you could help me I'd really appreciate it. These are both due tonight.
Questions. 50 fg
Which of the following is not an indication that a function is too complex?
Question 1 options:
1) it has a large size
2) it has a large parameter list
3) its name is a clear reflection of its function
4) it performs multiple tasks
Question 2 (1 point)
Which statement is false?
Question 2 options:
1) Every block is a compound statement.
2) Every compound statement is a block.
3) Blocks can be nested.
4) Compound statements can be nested.
Question 3 (1 point)
Placing a semicolon after the right parenthesis enclosing the parameter list of a function definition is a __________ error.
Question 3 options:
1) logic
2) syntax
3) fatal runtime
4) nonfatal runtime
Question 4 (1 point)
Which statement is false?
Question 4 options:
1) A recursive function is a function that calls itself either directly or indirectly through another function.
2) A recursive function knows how to solve only one or more base cases.
3) d) In order for the recursion to eventually terminate, each time the function calls itself with a slightly simpler version of the original problem, this sequence of smaller and smaller problems must eventually converge on a base case.
4) In order for the recursion to eventually terminate, each time the function calls itself with a slightly simpler version of the original problem, this sequence of smaller and smaller problems must eventually converge on a base case.
Question 5 (1 point)
What happens when you do not include math.h when using functions in the math library?
Question 5 options:
1) compilation error
2) execution error
3) logic error
4) strange results may occur
Question 6 (1 point)
A recursive function is a function that
Question 6 options:
1) returns a double
2) takes 3 arguments
3) calls itself
4) is inside of another function
Question 7 (1 point)
Which is not an attribute of a variable
Question 7 options:
1) name
2) definition
3) type
4) value
Question 8 (1 point)
Which statement is true?
Question 8 options:
1) When an argument is passed call by reference, a copy of the argument’s value is made and passed to the called function.
2) With call by reference, changes to the passed value do not affect the original variable’s value in the calling functions.
3) Call by value should be used whenever the called function does not need to modify the value of the caller’s original value.
4) Call by value should only be used with trusted called functions that need to modify the original variable.
Question 9 (1 point)
Which is not an attribute of a variable?
Question 9 options:
1) storage class
2) storage duration
3) scope
4) external class
Question 10 (1 point)
The type of a parameter whose type is omitted in a function defeinition is __________.
Question 10 options:
1) int
2) double
3) long
4) float
Question 11 (1 point)
What value does function mystery return when called with a value of 4?
int mystery ( int number ) {
if ( number <= 1 )
return 1;
else
return number * mystery( number – 1 );
}
Question 11 options:
1) 1
2) 24
3) 0
4) 4
Question 12 (1 point)
In the expression
n = a + rand() % b;
Question 12 options:
1) b
is the shifting value
2) a
is the scaling value
3) b
is equal to the width of the desired range of integers
4) both a and c
Question 13 (1 point)
Using the following function definition, the return value type is represented by
A B( C ) {
D
}
Question 13 options:
1) A
2) B
3) C
4) D
Question 14 (1 point)
All of the following are true of functions except:
Question 14 options:
1) they define specific tasks that can be used at many points in a program
2) a function call must specify the name and arguments of the function
3) the definition of a function is always visible to other functions
4) the implementation of a function is hidden from the caller
Question 15 (1 point)
The forcing of arguments to the appropriate types is commonly called __________.
Question 15 options:
1) conversion
2) casting
3) coercion
4) transmogrification
And my assignment that is due. 50 fg.
Assignment 5
Write a program using “recursion” function concepts that we discussed in class to do
a factorial of a number. The program should be interactive and describe what the
program is doing and also end with a “thank you note”. Hint: Use functions in the
program and you can use the n*fact(n-1) formula to calculate the factorial of n, the
number. (10 points)
The program should say something similar:
Welcome to my program that …………….
Please input a number for factorial calculation:
Your answer is:
Thank you for using my factorial program
Thanks guys!
This post was edited by jriehle87 on Oct 18 2012 05:57pm