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 do we use stdio h and conio h?

1081


what is the height of tree if leaf node is at level 3. please explain

2149


How would you use the functions fseek(), freed(), fwrite() and ftell()?

1161


What is a union?

1031


How reliable are floating-point comparisons?

1094


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

3713


Why c language?

1060


Dont ansi function prototypes render lint obsolete?

1124


Is there a way to compare two structure variables?

1111


Explain what will be the outcome of the following conditional statement if the value of variable s is 10?

1246


When do we get logical errors?

1123


Why is a semicolon (;) put at the end of every program statement?

1070


What are comments and how do you insert it in a C program?

1246


A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM

2121


What are global variables and how do you declare them?

1091