Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you Please help me with this code. This has to be in C. Thank you. Description: This daily is to write a program that

image text in transcribed

Can you Please help me with this code. This has to be in C. Thank you.

Description: This daily is to write a program that asks the user for a positive integer (greater than zero) Verify that you have received a valid number and trap the user if they have not given a valid input value Ask the user for another positive integer and verify this one also. Notice that the operation of getting a positive integer is the same in both cases. Use a single function, e.g., getlnt(), for this task that returns the positive integer that the user types in. Then you can simply call the function twice to get the values that you need Once you have two positive integers, use a function, which must be called getGCD. Your function will take 2 positive integers as arguments and return the largest integer that evenly divides both of the input values. The function should compute this value by starting at the smaller of the two values and counting down by one until you find a number (the number 1 will always do it) that evenly divides both of the original numbers. For example if you enter the number 8 and 4 your function will return 4 because 4 goes into 4 one time and into 8 two times. The function should return the largest integer to the main function. Print the result from the main function (but not within the function) Notice that you will need to write at least 2 functions, one to get a valid user input, and one to calculate. Your program output should look like the following rurn Please enter a positive integer: I m sorry, that number is unrecognized or not positive. Please enter a positive integer: I m sorry, that number is unrecognized or not positive. Please enter a positive integer: stop I m sorry, that number is unrecognized or not positive Please enter a positive integer: 20 Please enter a second positive integer: The largest integer that divides both 20 and 8 is: 4 5

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

2. What potential barriers would you encourage Samuel to avoid?

Answered: 1 week ago