The program should calculate total resistance of any two resistors

in parallel (R1 and R2) whose values should be any possible combination

of integer numbers between 1 and 100. The program should analyze

the output (RT), and display R1, R2, and RT on the screen if the

equivalent resistance RT is just a whole number (without decimals).

-----------------------------------------X------------------------------------------

Formula to calculate total resistance (RT) of two parallel resistors is:

RT= 1 / ((1/R1)+(1/R2))

could someone please guide me.

Rt=(float) (R1*R2)/(R1+R2);

//since R1 and R2 are int,the resultant is also int,so you need to cast the result of

//the division to a float to get the correct decimal values.

if(Rt-(int)Rt==0)

{

printf("R1:%d,R2:%d,Total resistance is: %.2f\n",R1,R2,Rt);

}

//Rt is a float,so casting it as an int will truncate the decimal part.

//If the difference of the float value and the int value is 0,then Rt is a whole number

Also,if you need to calculate the resistances for fractional values also,you can consider changing the datatypes of R1 and R2 to float as mercantilum has already pointed out.