Thursday, January 31, 2008

C prog to find remainder of a number

This prog finds remainder of a number without using divisor (/), modulus (%) or multiplication (*) operator.

#include
#include
main()
{
int a,b;

printf("enter the value of Dividend=");
scanf("%d",&a);
printf("enter the value of divisor=");
scanf("%d",&b);
if(a>=b)
{
while(a-b>=b)
{
a=a-b;
}
printf("the reminder is =%d",a-b);
}
else
printf(" Dividend must be greater than divisor");
getch();
}

No comments: