Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Why is this loop always executing once?

1110


Why c is procedure oriented?

1123


what will be maximum number of comparisons when number of elements are given?

1952


What is LINKED LIST? How can you access the last element in a linked list?

1117


Is it acceptable to declare/define a variable in a c header?

1180


illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question

2132


Why doesnt this code work?

1125


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

1203


What is the purpose of & in scanf?

1122


Write a program to print factorial of given number using recursion?

1065


What are the advantages and disadvantages of a heap?

1258


Difference between exit() and _exit() function?

1179


1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321

3785


What functions are used in dynamic memory allocation in c?

1122


What is 02d in c?

1111