Question
THIS NEEDS TO BE IN C Write a program that asks the user for a positive integer (greater than zero). Verify that you have received
THIS NEEDS TO BE IN C
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 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 to compute the largest integer that evenly divides both of the input values. Print this result on the screen. Your 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. Call this function and output the result on the screen. Notice that you will need to write at least 2 functions, one to get a valid user input, and one to calculate.
Example Output:
"Please enter a positive integer: -1
I'm sorry that number is unrecognized or not positive
Please enter a positive integer: 0
I'm sorry that number is unrecognized or not positive
Please enter a positive integer: 20
Please enter a second positive integer: 8
The largest integer that divdies both 20 and 8 is: 4
Press any key to continue..."
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