Assignment 2.1: Quotient
Specification
Implement a program in C in a file named quotient.c
with the following behavior:
- Get two integers from the user called the
dividend
and thedivisor
. - Print the floored quotient (result of floor division) AND the remainder (result of the modulo (%) operation) of that division. This is the result you would get from doing long division.
- Print the quotient (result of floating point division) to 3 decimal places.
- You don’t need to handle invalid inputs or include any comments for this assignment.
References
In addition to the assigned lecture chunk, you might want to refer to the short or reference sheet for Data Types from Chapter 1 and the Typecasting reference sheet from this chapter.
Example in/out:
dividend: 8
divisor: 3
floored quotient: 2
remainder: 2
quotient: 2.667
dividend: 9
divisor: 3
floored quotient: 3
remainder: 0
quotient: 3.000
dividend: 99
divisor: 25
floored quotient: 3
remainder: 24
quotient: 3.960
dividend: 99
divisor: 0
Floating point exception
Check & Submit
Check style with style50:
style50 quotient.c
Check functionality with check50:
check50 cs-acs/problems/main/quotient
Submit with submit50:
submit50 cs-acs/problems/main/quotient