Computer Science, asked by crushbomb88, 11 months ago

2.3 Code Practice: Question 1
Write a program that prompts the user to input two numbers, a numerator and a divisor. Your program should then divide the numerator by the divisor, and display the quotient and remainder.

Answers

Answered by AmartyaChowdhury
23

PYTHON 3 CODE :

num = float(input("Enter numerator : "))

den = float(input("Enter denominator : "))

quotient = str(num//den)

remainder = str(num%den)

print("Quotient is " + quotient + " and remainder is " + remainder + ".")

Answered by ExieFansler
4

Answer:

#include <iostream>

using namespace std;

int main() {

int rem;

float numerator,divisor,quotient;

cout<<"Enter the numerator and divisor"<<endl;

cin>>numerator>>divisor;//taking the input.

quotient=numerator/divisor;

rem=int(numerator)%int(divisor);//calculating the remainder.

cout<<"The quotient is "<<quotient<<endl;//printing the quotient..

cout<<"The remainder is "<<rem<<endl;//printing the remainder..

return 0;

}

Output:-

Enter the numerator and divisor

11 5

The quotient is 2.2

The remainder is 1

Explanation:

I have taken 3 float variables numerator,divisor,quotient to store respective numerator,divisor,quotient.To calculate quotient we use division operator / and to find out the remainder we use % modulus operator and this operator works with integers only.So I have done typecasting to convert them into integer.

Similar questions