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 is = symbol different from == symbol in c programming?
Why do we use stdio h and conio h?
What are the storage classes in C?
Which is the memory area not included in C program? give the reason
I need a sort of an approximate strcmp routine?
Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant
What is the use of function overloading in C?
What is main () in c language?
Write a simple code fragment that will check if a number is positive or negative.
Explain how can you avoid including a header more than once?
What are nested functions in c?
Describe static function with its usage?
How can a program be made to print the name of a source file where an error occurs?
What are types of structure?
Why c language?