How to find remainder of two numbers without using (%)
operator



How to find remainder of two numbers without using (%) operator..

Answer / shubham

using formula "Dividend = Quotient x Divisor + Remainder"
the c++ code for this would be

#include<iostream.h>
void main()
{
int a,b,q,r;
cout<<"Enter a ";
cin>>a;
cout<<"Enter b ";
cin>>b;
q=a/b;
r=a-q*b;
cout<<"Remender="<<r;
}

Is This Answer Correct ?    16 Yes 1 No

Post New Answer

More General Aptitude Interview Questions

15 : 50 :: 18 : ? (A) 55 (B) 59 (C) 64 (D) 62 answer is 59 but how?

4 Answers   FCI,


to write a number in words eg. FIVE requires 10 straight lines. what is the number which requires the same number of lines as that of the number itself

13 Answers   Franklin Templeton, TCS, Vcustomer,


Differnce between RAM and ROM

1 Answers   Bhushan Power Steel, eClerx,


5) DB2 maintains information about the data a) In Tables b) In a set of tables known as DB2 catalog c) In DB2 database d) None of the above

0 Answers   Infosys,


Number Series 11,14,12,15,13,16,?

14 Answers   TCS,






To get a parabola if you cut a section of?

5 Answers   Geometric Software,


28% of 450 + 45% of 280 = ? (a) 126 (b) 252 (c) 324 (d) 212 (e) None of these

5 Answers  


3x + 4y =15 so what is the slope of line which is perpendicular to this line.?

4 Answers  


There are 5 red shoes, 4 green shoes. If one draw randomly a shoe what is the probability of getting red shoe

0 Answers   Ramco,


Find the hypotenuse of a right angle isoceles triangle whose area is 50.

0 Answers   Citicorp,


A lorry averages 55mph for the first 4 hours of a trip and averages 70 mph for each additional hour. The average speed for entire trip was 60 mph. How many hours long is the trip? a)14 b)12 c)11 d)8 e)6

3 Answers  


A man engaged a servant on a condn that he’ll pay Rs 90 and also give him a bag at the end of the yr. He served for 9 months and was given a turban and Rs 65. So the price of turban is i. Rs : 10 19 0 55

9 Answers   Accenture, Cap Gemini,


Categories