# C Program To Find Modulus of Two Numbers

In this post, we will learn how to find the modulus of two numbers using C Programming language.

This program will ask the user to enter the value of the dividend and the divisor, then it will calculate the remainder with the help of the Modulus(%) operator.

So, without further, let’s begin this tutorial.

Contents

## C Program To Find Modulus of Two Numbers

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

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

rem = num1 % num2;
printf("Remainder = %d", rem);
return 0;
}
```

Output

``````Enter the dividend: 62
Enter the divisor: 7
Remainder = 6``````

## How Does This Program Work ?

```  int num1, num2, rem;
```

In this program, we have declared three int data type variables named as num1, num2 and rem which will store the values of dividend, divisor and the remainder respectively.

```  //Asking for input
printf("Enter the dividend: ");
scanf("%d", &num1);
printf("Enter the divisor: ");
scanf("%d", &num2);
```

Now, the user is asked to enter the values of the dividend and the divisor.

```  rem = num1 % num2;
```

We calculate the remainder using the Modulus(%) operator.

```  printf("Remainder = %d", rem);
```

Finally, the result is displayed to the screen using printf() function.

## Conclusion

I hope after going through this post, you understand how to find the modulus of two numbers using C Programming language.

If you have any doubt regarding the program, feel free to contact us in the comment section. We will be delighted to help you.

1. 