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",&dividend,&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


Please Help Members By Posting Answers For Below Questions

What is string concatenation in c?

575


Explain heap and queue.

591


Can you return null in c?

603


What is bubble sort in c?

646


How can I run c program?

696






what are bit fields? What is the use of bit fields in a structure declaration?

1506


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..

1598


What is the symbol indicated the c-preprocessor?

702


Can we declare variable anywhere in c?

545


how to build a exercise findig min number of e heap with list imlemented?

1618


What are structural members?

578


In which header file is the null macro defined?

863


What functions are used for dynamic memory allocation in c language?

610


Is there any possibility to create customized header file with c programming language?

630


Why do we use c for the speed of light?

612