Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions

Question

How do members envision the ideal team?

Answered: 1 week ago

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago