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

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including 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. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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