Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with these last couple problems for my homework. Please help, Thank you. Question 2 20 pts In this question, please write a

I need help with these last couple problems for my homework. Please help, Thank you.image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Question 2 20 pts In this question, please write a function daysInMonth, that takes the year and month as two integer arguments and returns the number of days in that month. Use the function "isLeap Year" from the previous problem (you can assume that it works) to accommodate for leap years. Make sure your function is syntactically correct. You can assume that the year will be greater than 0 and that the month will take the values (1-12]. HINT: Days in the month can be 28,29,30, or 31. Think about the cases each of these occur. x BIU A - A - IX E N N Vx neto E HTML Editora := = Para G V T 12pt Question 3 20 pts Convert the following for loop to an equivalent while loop: int index = 0; int testArray[10]; for (index = 0; index 0) testArray[index] *= testArray[index-1]; What are the final values inside testArray? Write your answer in [0,1,2,3,4,5,...] format. B x I VA - A DP N - Ix E Va to E ? x 12pt HTML Editore := = Para Question 4 20 pts Please write a function printFibonacci, that takes the number of terms to print as an integer argument and returns nothing. Use UARTprintf to print out each of the Fibonacci sequence. Use an iterative for loop for this problem. You can assume that all the necessary includes are already done (just right the function) and that the number of terms is greater than 0. HINT: Fibonacci sequence is Fib(n) = Fib(n-1) + Fib(n-2) where Fib(O) = 0 and Fib(1) = 1. For example, if printFibonacci receives 5 as input, it should print the sequence "O, 1, 1, 2, 3" HTML Editora BI VA - A - Ix 3 3 3 3 3 x x := = N Vx Moto G V D 1 12pt - Para E Question 5 20 pts There are two errors in the following code, please indicate what line number they are on and how to fix it. It may be functional or syntactical. The following code finds the two highest values (saves highest in max1 and second highest in max2) in an array called testArray. 1. int testArray[100]; 2. int index = 0; 3. int max1 = 0; 4. int max2 = 0; 5. for(index = 0; index max1) 8. { max1 = testArray[index]; 10. max2 = max1; 11. } 12. else if (testArray[index] > max2); 13. { 14. max2 = testArray[index]; 15. } 16. } ma HTML Editore BI VA - A - Ix 5 3 3 3 3 x x := = E N Vx neto G V 12pt - Para

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

3. How is money associated with subjective well-being?

Answered: 1 week ago