Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Programming Lab Lab Procedures Setup The following steps will help you set up the lab. 1. Create a new folder in your OneDriveCISC130 folder,

C Programming Lab

Lab Procedures

Setup

The following steps will help you set up the lab.

1. Create a new folder in your OneDrive\CISC130 folder, and name it Lab09.

2. In Code::Blocks, make a new c file. Title it name1_name2_utilities.c and save it in the folder

you created above. Your names take the place of nameX above.

3. Make sure your complete first and last names are at the top of the file in comments.

4. Ensure that you have executing code that you have built and run prior to turning in your assignment. Test

your code and make sure it works for all equivalent inputs.

Activities

Today we will be solving some fun problems using recursion. You are NOT allowed to split up the tasks. All

group members must participate in solving each task. Your tasks are as follows:

0. Write a function that prints out your names.

1. Write a function that asks the user (I/O can be handled within the function) to enter a positive integer. If

the user enters a negative integer, warn them and then keep prompting them until they enter a positive

one. Your function should return the positive integer entered. You are not allowed to use a loop.

2. Write a recursive function for fast powering (it should work faster than the way we wrote it in class). It

should take an integer base and exponent; your function should return the base raised to the exponent. For

full credit, your function should leverage the fact that x^8 = x^4*x^4 and x^13=x^6*x^6*x. No loops are

allowed in this function.

3. Write a function that displays the Jarvis Sequence. You are not allowed to use loops. The Jarvis Sequence

is calculated as follows:

a. Take any positive integer n

b. Print n

c. If n is even, divide it by 2

d. If n is odd, multiply it by 3 and add 1

e. Repeat this process and print each integer in the sequence. Stop when n=1.

4. Write a function that takes an array and its size and fills the array with random numbers ranging from 7

to 320 (inclusive). You may not use loops.

5. Write a function that takes an integer array and its size and prints the array. Put commas between the

elements with the exception of the last element and, you guessed it, no loops.

6. Write a function that takes two integer arrays of the same size and copies the first one into the second one

after reversing the array. You will need additional function parameters to accomplish this. No loops.

7. Write a function that takes an integer x, an integer array, and the arrays size. It should return the number

of times x appears in the array. No loops.

8. Finally, create a driver.c file and a utilities.h file that uses all of these functions to generate the following

output (notice that every time a number needs to be entered the function from 1 is used.) Your output

should match exactly. Make your functions as atomic as possible. Driver.c should handle I/O.image text in transcribed

Example 1: FAST POWERING: elect a base Please enter a positive number: 6 Select an exponent Please enter a positive number:6 6646656 JARUIS SEQUENCE elect a start number Please enter a positive number 35 he Jarvis Sequence for 35 is: 35, 106, 53. 160. 80. 40, 20. 10. 5, 16. 8. 4. 2. 1 RANDOM ARRAY elect an array size Please enter a positive number: 15 175. 222, 228, 57. 39. 57, 182, 75. 156, 77. 110. 156, 250. 67?, 138 BACKWARD ARRAY ere is your array backward: 138. 67. 250. 156, 110. 77. 156. 75, 182. 57, 39. 57. 228. 222. 175 OW MANY TIMES IS IT IN THE ARRAY elect a number to search for Please enter a positive number 57 57 as in there 2 times Example 2 - with errors: FAST POWERING: Select a base Please ente a positive number: -6 ERROR: the number must be positive Please enter a positive number-8 ERROR: the number must be positive. Please enter a positive number-2 ERROR: the number must be positive Please enter a positive number:5 Select an exponent Please enter a positive number:-4 ERROR: the number must be positive Please enter a positive number ? 5 778125 ARUIS SEQUENCE Select a start number Please enter a positive number:-6 ERROR: the nunber must be positive Please enter a positive number:-26 ERROR: the nunber must be positive Please enter a positive number: 22 The Jarvis Sequence for 22 is: 22, 11. 34, 17, 52. 26, 13. 40, 20. 10. 5, 16. 8. 4, 2. 1 RANDOM ARRAY elect an array size Please enter a positive number: 17 163, 125, 66, 86, 213, 17, 20, 134, 193, 232, 39, 244, 218, 53, 154, 46, 180 BACKWARD ARRAY Here is your 180, 46,154, 53, 218, 244, 39, 232, 193, 134, 20, 17, 213, 86, 66, 125, 163 array backward: HOW MANY TIMES IS IT IN THE ARRAY Select a number to search for Please enter a positive number:2 2 was in there times

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

Microsoft Visual Basic 2008 Comprehensive Concepts And Techniques

Authors: Gary B. Shelly, Corinne Hoisington

1st Edition

1423927168, 978-1423927167

More Books

Students also viewed these Databases questions

Question

7. It is advisable to do favors for people whenever possible.

Answered: 1 week ago

Question

9. Power and politics can be destructive forces in organizations.

Answered: 1 week ago