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
What is string concatenation in c?
Explain heap and queue.
Can you return null in c?
What is bubble sort in c?
How can I run c program?
what are bit fields? What is the use of bit fields in a structure declaration?
If i have an array 0 to 99 i.e,(Size 100) I place the values 1 to 100 randomly like a[0]=29,a[1]=56 upto array[99].. the values are only between 1 to 100. getting the array values by using scanf.. If i entered one wrong element value line a[56]=108. how can i find it.. and also how to find the missing value in 1 to 100.. and i want to replace the missing values.. any one of them know please post your answer..
What is the symbol indicated the c-preprocessor?
Can we declare variable anywhere in c?
how to build a exercise findig min number of e heap with list imlemented?
What are structural members?
In which header file is the null macro defined?
What functions are used for dynamic memory allocation in c language?
Is there any possibility to create customized header file with c programming language?
Why do we use c for the speed of light?