program to get the remainder and quotant of given two
numbers with out using % and / operators?

Answer Posted / venkat raj

#include<stdio.h>
#include<conio.h>



int remainder;

void main()
{
int dividend, divisor;
int quotient;
int division(int,int);

printf("Enter the value of Dividend and Divisor\n");
scanf("%d %d",&dividend,&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=0,tempdivisor = divisor;


if(dividend == divisor)
{

remainder=0;
return 1;
}
else if (dividend < divisor)
{

remainder=1;
return 0;
}

while(tempdivisor <= dividend)
{
tempdivisor = tempdivisor + divisor;
quotient = quotient++;
}
remainder=dividend-(tempdivisor-divisor);



return quotient;



}

Is This Answer Correct ?    18 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

a=10;b= 5;c=3;d=3; if(a printf(%d %d %d %d a,b,c,d) else printf("%d %d %d %d a,b,c,d);

649


The statement, int(*x[]) () what does in indicate?

649


What are the storage classes in C?

629


What is your stream meaning?

610


What are the primitive data types in c?

579






What are valid signatures for the Main function?

703


Can I initialize unions?

596


write a program to copy the string using switch case?

2404


What is string in c language?

630


while initialization of array why we use a[][2] why not a[2][]...?

1869


What is the difference between exit() and _exit() function?

610


Write a program to generate the Fibinocci Series

673


What is memory leak in c?

639


Where are the auto variables stored?

628


What is a const pointer in c?

675