VOOZH about

URL: https://www.geeksforgeeks.org/c/c-program-to-compute-quotient-and-remainder/

⇱ C Program to Compute Quotient and Remainder - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C Program to Compute Quotient and Remainder

Last Updated : 11 Jul, 2025

Given two numbers A and B. The task is to write a program to find the quotient and remainder of these two numbers when A is divided by B.

👁 Quotient Remainder explained
 


Examples

Input: A = 2, B = 6
Output: Quotient = 0, Remainder = 2

Input: A = 17, B = 5
Output: Quotient = 3, Remainder = 2

1. Using Division and Modulo Operator

In the below program, to find the quotient and remainder of the two numbers, the user is first asked to enter two numbers. The inputs are scanned using the scanf() function and stored in the variables A and B. Then, the variables A and B are divided using the arithmetic operator / to get the quotient as the result stored in the variable quotient; and using the arithmetic operator % to get the remainder as the result stored in the variable remainder

Below are the programs to find the quotient and remainder of two numbers:  


Output
Enter two numbers A and B: Quotient when A / B is: 3
Remainder when A / B is: 2

The complexity of the above method

Time Complexity: O(1)

Auxiliary Space: O(1)

2. Using Loops

Below is the C program to find the quotient and remainder using loops:


Output
Quotient when A/B is: 3
Remainder when A/B is: 2

3. Using Functions

Below is the program to find the quotient and remainder of a number using functions:


Output
Quotient when A/B is: 3
Remainder when A/B is: 2
Comment
Article Tags: