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

How is = symbol different from == symbol in c programming?

990


Why do we use stdio h and conio h?

1037


What are the storage classes in C?

1074


Which is the memory area not included in C program? give the reason

1899


I need a sort of an approximate strcmp routine?

988


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

1088


What is the use of function overloading in C?

1104


What is main () in c language?

1080


Write a simple code fragment that will check if a number is positive or negative.

1103


Explain how can you avoid including a header more than once?

1045


What are nested functions in c?

979


Describe static function with its usage?

1156


How can a program be made to print the name of a source file where an error occurs?

1177


What are types of structure?

1068


Why c language?

1009