C Program to Find Quotient and Remainder

C program to find quotient and remainder; Through this tutorial, we will learn how to find quotient and remainder based on the dividend & divisor values entered by user in c program.

Algorithm and Programs to Find Quotient and Remainder in C

Algorithm and program to find quotient and remainder in C:

  • Algorithm to Find Quotient and Remainder
  • C Program to Find Quotient and Remainder
  • C Program to Find Quotient and Remainder using function

Algorithm to Find Quotient and Remainder

Use the following algorithm to write a program to find quotient and remainder; as follows:

  • Step 1: Start program.
  • Step 2: Read two numbers from user and store them into variables.
  • Step 3: Multiply two floating point numbers and store result in variable.
  • Step 4: Print multiply two floating point numbers.
  • Step 5: End program.

C Program to Find Quotient and Remainder

#include <stdio.h>
int main(){
   int num1, num2, quot, rem;

   printf("Enter dividend: ");
   scanf("%d", &num1);

   printf("Enter divisor: ");
   scanf("%d", &num2);

   /* The "/" Arithmetic operator returns the quotient
    * Here the num1 is divided by num2 and the quotient
    * is assigned to the variable quot
    */
   quot = num1 / num2;

   /* The modulus operator "%" returns the remainder after
    * dividing num1 by num2.
    */
   rem = num1 % num2;

   printf("Quotient is: %d\n", quot);
   printf("Remainder is: %d", rem);

   return 0;
}

The output of the above c program; as follows:

Enter dividend: 10
Enter divisor: 5
Quotient is: 2
Remainder is: 0

C Program to Find Quotient and Remainder using function

#include <stdio.h>
// Function to computer quotient
int quotient(int a, int b){
   return a / b;
}

// Function to computer remainder
int remainder(int a, int b){
   return a % b;
}

int main(){
    int num1, num2, quot, rem;
    printf("Enter dividend: ");    
    scanf("%d", &num1);
    printf("Enter divisor: ");    
    scanf("%d", &num2);
    
    //Calling function quotient()    
    quot = quotient(num1, num2);

    //Calling function remainder()    
    rem = remainder(num1, num2);
    printf("Quotient is: %d\n", quot);    
    printf("Remainder is: %d", rem);
    return 0;
}

The output of the above c program; as follows:

Enter dividend: 50
Enter divisor: 2
Quotient is: 25
Remainder is: 0

Recommended C Programs

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *