Program to calculate the Remainder and Quotient in C Language

Remainder-and-Quotient-in-C-programming-language

Remainder and Quotient in C Description:

Write a Program to calculate the Remainder and Quotient in C language. The program should accept two numbers from the user and calculate the Remainder and Quotient.

We should not allow the second number to be zero. Because if the second number is zero then we will get the Floating point exception.

📢 Don’t allow Floating point exceptions

Excepted Output:

Example 1:

Input:

Output:

Example 2:

Input:

Output:

Example 3:

Input:

Output:

PreRequisites:

We need to know the basics of Division and modulo division operations and decision-making statements. Please look at the following articles to learn more about them

Remainder and Quotient in C Program Explanation:

  • The program will accept two numbers from the user and store them in variables num1 and num2.
  • Now we need to check if the num2 is zero, If num2 is zero, Then we can’t calculate the Remainder and Quotient of the num1 and num2.
  • So Display the Error message and Prompt the user for new input.
  • If the num2 is not zero, Then we can calculate the Remainder and Quotient.
  • We use the Division Operator to calculate the Quotient ( quo = num1 / num2)
  • Then we calculate the Remainder using the Modulo division Operator. ( rem = num1 % num2)
  • Finally, we print the result on the console.

Program – Remainder and Quotient in C Language:

Program Output:

Related Programs:

More C Programs:

C Tutorials Index:

Venkatesh

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

1 Response

  1. […] C Program to Calculate the Remainder and Quotient […]

Leave a Reply