Translate

Labels

Tuesday 26 March 2013

DIVISION WITHOUT OPERATOR ' / '

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,i,t,s=0;
clrscr();
printf("Enter two numbers to divide \n");
printf("A,B :");
scanf("%d,%d",&a&b);
if(a>b)
{
t=a;
a=b;
b=t;
}
s=b;
for(i=1;i<=b;i++)
{
s=s-a;
if(s<b)
break;
}
printf("\n Your answer is");
printf("\n %d(quotient),%d(remainder)",i,s);
getch();
}
OUTPUT
Enter two number to divide
A,B:25,39
Your answer is 
1(quotient),14(remainder)

No comments: