C Program to find modulus of two numbers

Get two integer numbers, divide both the integers and display the remainder.

Sample Input 1:

6 5

Sample Output 1:


Sample Input 2:

28 4

Sample Output 2:


Try your Solution

Strongly recommended to Solve it on your own, Don't directly go to the solution given below.

#include<stdio.h> int main() { //write your code here }

Program or Solution

//Program to get remainder in division
int main()
	int num1,num2,rem;
	printf("Enter two numbers:");
	scanf("%d %d",&num1,&num2);
	printf("\nRemainder: %d",rem);
	return  0;

Program Explanation

Get two integers a and b (using scanf statement) divide a by b, then store quotient in c (c=a%b, Note "%" operator gives remainder) print the value of c (using printf statement)