Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program needs to be done in C can anyone help? Edit, compile, and run the following program on the UH UNIX shell: Write a

This program needs to be done in C can anyone help?

Edit, compile, and run the following program on the UH UNIX shell:

Write a program with a main() function and the following five (5) functions definitions (and corresponding function prototypes and function calls).

1) You will be inputting numbers, so at the top of your program, include the getdouble.h header file: #include "getdouble.h"

2) Ask the user to "Enter two positive integers, separated by a space, the first smaller than the second".

3) Use function getdouble() twice to get the two integers from the user. For example: int first = (int)getdouble(); int last = (int)getdouble();

4) Do NOT use function scanf(), because it is easy for someone to crash your program with this function.

5) Do some error checking on the input.

6) Use recursion to display the integers from the first integer to the second integer. The return type should be "void". Use printf() statements in your function to display the integers.

7) Use recursion to add the sum of the integers from the first integer to the second integer. The return type should be "int". Display the result in main().

8) Use recursion to multiply the product of the integers from the first integer to the second integer. The return type should be "int".

9) Use recursion to calculate the first integer to the power of the second integer. The return type should be "int". Display the result in main(). Please do NOT use the C library pow() function.

10) Use recursion to calculate the GCD (greatest common divisor) of the first integer and the second integer. The GCD is the largest integer that divides both x and y. The base case is: if y is equal to 0, then the return value is x. The recursive case is: The return value is gcd(y, x%y). The return type should be "int". Display the result in main().

Email your makefile and C program to the instructor, or show it to the instructor in class.

For the submission guidelines and the grading guidelines, see the syllabus.

Example I/O

Enter two positive integers, separated by a space, the first smaller than the second: 5 1 ERROR: 5 is not smaller than 1 Enter two positive integers, separated by a space, the first smaller than the second: -1 5 ERROR: both numbers must be positive Enter two positive integers, separated by a space, the first smaller than the second: 1 5 Counting from 1 to 5: 1 2 3 4 5 The sum of 1 to 5 = 15 The product of 1 to 5 = 120 1 to power of 5 = 1 The GCD of 1 and 5 = 1 Counting from 2 to 6: 2 3 4 5 6 The sum of 2 to 6 = 20 The product of 2 to 6 = 720 2 to power of 6 = 64 The GCD of 2 and 6 = 2 Counting from 6 to 9: 6 7 8 9 The sum of 6 to 9 = 30 The product of 6 to 9 = 3024 6 to power of 9 = 10077696 The GCD of 6 and 9 = 3 

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

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions

Question

How to reverse a Armstrong number by using double linked list ?

Answered: 1 week ago

Question

=+Understand the fi eld of comparative IHRM.

Answered: 1 week ago