Find the remainder without using % (Modulus operator)?
#include <stdio.h>
int main()
{
int num,div,rem=0;
printf("enter the number and divisor\n");
scanf("%d %d",&num,&div);
if(num!=0 && div !=0)
{
rem=num/div;
rem*=div;
rem=num-rem;
printf("without modulus= %d\n",rem);
}
printf("with modulus\t=%d",num%div);
}
output:-
enter the number and divisor
25 7
without modulus= 4
with modulus =4
0 కామెంట్లు