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",÷nd,&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
Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?
What is the difference between text and binary modes?
How can I rethow can I return a sequence of random numbers which dont repeat at all?
How can I change the size of the dynamically allocated array?
What are the types of arrays in c?
How can I recover the file name given an open stream?
Can you please explain the difference between malloc() and calloc() function?
What is a double c?
to find the closest pair
Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above
How can I invoke another program (a standalone executable, or an operating system command) from within a c program?
What type is sizeof?
Give the rules for variable declaration?
What is malloc return c?
What is the mean of function?