Reference no: EM13936820
C++ Examples #1
1.When two or more functions have the same name, how does the compiler determine which one to use for a particular function call?
2. Write a void function called Orderme that takes two integer reference parameters a and b, and sets to the larger of the two ints, and b to the smaller. Write another Order function that takes two double arguments. Write a short main function that calls both functions and demonstrates that they work. Cout statements should only appear in function main.
3. Rewrite your answer for the previous question, using a single Order template instead of two Order functions. If done correctly,the main() function should not change.
4. What value is returned by the call F(3) where F is the recursive function given by the following code? Explain how you arrived
at your answer.
int F (int N)
{
if (N == 0)
return 1;
else
return (2 * F(N - 1));
}
5. Consider the following function:
int surprise(int number) {
if (number == 1)
return 1;
else
return number * surprise(number -1 );
}
a. What value does function surprise return when called with a value of 4?
b. What is the base case for function surprise?
6. Write an iterative (non-recursive) function that takes a number of years and a compound interest rate (as a percentage) and computes what a $1000 investment would have grown to in that many years at that interest. For example, given 3 for years and .1 (representing 10%) as the rate, the result would be $1331. Use a loop to calculate the result (don't use the pow function).
7a. Rewrite your function for the previous question as a recursive function.
7b. Which function do you think is easier to read?
7c. Which function do you find easier to write?
8. What does it mean to modularize a program? What are the benefits?
9. Consider a program that reads two whole numbers from the user, computes the greatest common divisor, and displays the results to the user.Write a program for this task where all code is within the main function.
10a. Rewrite your solution to the previous question as a modular program, using additional functions as much as possible.
10b. Which version of the program is shortest? Which version is easiest to read--and why?
How the pyrosequencing method has been useful
: Explain the two main methods of sequencing, the dideoxy (Sanger) method and the basic method of 'pyrosequencing'
|
Discuss the target market and positioning strategies
: Discuss the target market and positioning strategies for each of the above CB strategies and suggest other segments that M&S might be able to successfully target.
|
An automotive mechanical repair business
: Boyle's Mobile Automotive Services is an automotive mechanical repair business that carries out mechanical repairs and services at the customers place of residence. The owner, Mr Lance A. Boyle, requires a Java program to assist his business to ma..
|
Explain main methods of sequencing, the dideoxy method
: Explain the two main methods of sequencing, the dideoxy (Sanger) method and the basic method of 'pyrosequencing', Mechanistic details for both Sanger and Pyrosequencing are provided.
|
How compiler determine when 2 functions have same name
: When two or more functions have the same name, how does the compiler determine which one to use for a particular function call?
|
How is social media impacting firms individuals and society
: How do recent changes in computing impact consumers? Are these changes good or bad? Explain. How do they impact businesses? How is social media impacting firms, individuals, and society
|
Use appropriate classes, fields, methods, objects
: The summary information required by the University is the number of students and guests at each ceremony the total number of students and guests at all three ceremonies the ratio of students to guests at each of the three ceremonies.
|
Ppportunities does the existence of the buffett community
: How can we consider Jimmy Buffett fans as members of a reference group? A brand community? 2 Refer to your responses to question 1. What kind of opportunities does the existence of the Buffett community.
|
Car hire database including appropriate data
: This assignment prepares you for the examination and you should consider each hour devoted to the assignment as an hour devoted to exam preparation.
|