Design how to do the logic in your own words first do not


Objectives

- Gain experience with if, if else, and switch statements in C programs.
- Experience using % operator and true false logic.

Hints

This program will be MUCH easier if you design how to do the logic in your own words first. Do not even think about C until you understand the true false logic and the arithmetic needed to do it. Make sure you have a formula or a plan to calculate each case.

The program

The user types in two numbers to find if the first is evenly divisible by the second.

The program will output:
is evenly divisible by
Or
is too large to be evenly divisible by . The closest number is .
Or
is too small to be evenly divisible by . The closest number is .
Or
is off, in the middle from or

Examples:
User types 49 and 7.
49 is evenly divisible by 7.
User types 50 and 7.
50 is too large to be evenly divisible by 7. The closest number is 49.
User types 55 and 7.
55 is too small to be evenly divisible by 7. The closest number is 56.
User types 52 and 8.
52 is 4 off, in the middle from 48 or 56.

Rules:

You must use nested if, else if statements to do your logic.

The program must only return at one place, the bottom of main(), with no exit() and no break statements.

Rules for programming assignments

If you break any of these rules your will receive a 0 on your assignment and will have to rewrite it and resubmit.

1. All variables must be declared BEFORE ANY CODE.

2. No variables declared in loops like for(int x; The int x must be at the top of your code. See rule 1.

3. No use of break or continue in loops.

4. Functions that return a value must have one and only one return statement, the last line in the function.

5. All variable must have meaningful names. For rows and columns must be r and c or row and col or row and column. Not i, j, a, b or anything not meaning full.

6. Code must be properly indented and formatted.

7. All assignments must have comments at the top that:
a. Name of assignment, class, and the date.
b. Name of the author: that would be you

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Design how to do the logic in your own words first do not
Reference No:- TGS01599588

Expected delivery within 24 Hours