Easy Tutorial
❮ C Examples Access Array Pointer C Function Mktime ❯

C Language Example - Division of Two Numbers

C Language Examples

Divide two numbers and output the remainder if there is one.

Example

#include <stdio.h>

int main(){

    int dividend, divisor, quotient, remainder;

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

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

    // Calculate the quotient
    quotient = dividend / divisor;

    // Calculate the remainder
    remainder = dividend % divisor;

    printf("Quotient = %d\n", quotient);
    printf("Remainder = %d", remainder);

    return 0;
}

Running result:

Enter the dividend: 5
Enter the divisor: 2
Quotient = 2
Remainder = 1

C Language Examples

❮ C Examples Access Array Pointer C Function Mktime ❯