Computer Science, asked by come22sunil, 21 days ago

.Write a Program to Compute Quotient and Remainder in C language​

Answers

Answered by anindyaadhikari13
2

Solution:

The given problem is solved in C.

#include <stdio.h>

int main() {

   int a, b, q, r;

   printf("Enter first number: ");

   scanf("%d", &a);

   printf("Enter second number: ");

   scanf("%d", &b);

   q = a / b;

   r = a % b;

   printf("Quotient: %d\nRemainder: %d", q, r);

   return 0;

}

Explanation:

  • At first, we ask the user to enter the numbers.
  • Then we calculate the quotient by dividing the first number by the second. Since, the two numbers are of integer data type, dividing one by other gives the quotient due to integer division.
  • Now, to calculate the remainder, we will use modulus operator.
  • Modulus operator calculates the remainder obtained after division. So, if two numbers are a and b, a % b gives the remainder obtained.

Refer to the attachment for output.

Attachments:
Similar questions