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
Why is this loop always executing once?
Why c is procedure oriented?
what will be maximum number of comparisons when number of elements are given?
What is LINKED LIST? How can you access the last element in a linked list?
Is it acceptable to declare/define a variable in a c header?
illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question
Why doesnt this code work?
any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above
What is the purpose of & in scanf?
Write a program to print factorial of given number using recursion?
What are the advantages and disadvantages of a heap?
Difference between exit() and _exit() function?
1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321
What functions are used in dynamic memory allocation in c?
What is 02d in c?