Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In C++ please, thank you! Assume you get a job with a starting salary of $50 k/year. Every year, your salary increases by 10%, plus
In C++ please, thank you!
- Assume you get a job with a starting salary of $50 k/year. Every year, your salary increases by 10%, plus a 5 k linear increase. So your salary for the second year will be 50*1.1 + 5 = 60 k. In this problem, you will write a recursive function to compute your salary for year n. The answers to part a and b will help you write your recursive function
- What is your salary at time 0?
- If your salary for year n-1 is sn-1 then what is your salary for year n?
- Write a recursive function int salary(int n) to compute your salary for year n. Only recursive solutions allowed.
- Test your function in your main().
2. In this problem, you will be asked questions to help you write a recursive function
bool isSorted(int a[], int n)
to determine whether an array a is in sorted order. An array is in sorted order if a[0] a[1] a[2] a[n-1].
- How do you tell if an array with two elements is sorted?
- Assume that the first n-1 elements in the array are sorted. How do you tell if the array is still sorted when you add the nth element?
- Write a recursive function bool isSorted(int a[], int n) that returns true if the first n elements of the array a are in sorted order, and false otherwise. Your function must be recursive.
- Test your function in your main().
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started