program to get the remainder and quotant of given two
numbers with out using % and / operators?
Answer Posted / santhi perumal
#include<stdio.h>
#include<conio.h>
int remainder, tempdevisor ,i = 0;
int division(int,int);
int main()
{
int dividend, divisor;
int quotient;
printf("Enter the value of Dividend and Divisor\n");
scanf("%d %d",÷nd,&divisor);
tempdevisor = divisor;
quotient = division(dividend,divisor);
printf("The Quotient is %d\n",quotient);
printf("The Remainder is %d\n",remainder);
}
int division(int dividend,int divisor)
{
int quotient = 1;
i++;
if(dividend == divisor)
{
remainder = 0;
return 1;
}
else if (dividend < divisor)
{
remainder = dividend;
return 0;
}
while(divisor <= dividend)
{
divisor = divisor<<1;
quotient = quotient<<1;
}
divisor = divisor>>1;
quotient = quotient>>1;
// printf("Quotient in the %d iteration is %d\n",i,quotient);
quotient = quotient + division(dividend-divisor,tempdevisor);
return quotient;
}
| Is This Answer Correct ? | 16 Yes | 16 No |
Post New Answer View All Answers
How can I prevent another program from modifying part of a file that I am modifying?
what do u mean by Direct access files? then can u explain about Direct Access Files?
What are the disadvantages of external storage class?
Explain how can I manipulate strings of multibyte characters?
What is extern c used for?
What is an endless loop?
Is c is a high level language?
What is sizeof c?
Explain what is the benefit of using const for declaring constants?
Using which language Test cases are added in .ptu file of RTRT unit testing???
Can include files be nested?
What is a header file?
What is a void pointer? When is a void pointer used?
Explain data types & how many data types supported by c?
How is a pointer variable declared?