Programming Logics FORUMS

Full Version: C Programming help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am using Microsoft Visual Studio. i'm having trouble with one part.
#include <stdio.h>
Code:
void main(void)
{
float r1, r2, r3, V, I, R;

/* input */
printf("Enter the value of the 3 resistances: ");
scanf("%f %f %f", &r1 &r2 &r3);
printf("Enter the value of voltage: ");
scanf("%f", &V);

/* calculate the equivalent resistance */
R = r1 + (1 / (1 / r2 + 1 / r3) );

/* calculate the current */
I = V / R;

/* output */
printf("Voltage = %fV\n", V);
printf("Equivalent resistance = %f ohm\n", R);
printf("Current = %f A", I);
} // end main
the output is supposed to be like this
Enter the values of the 3 resistances: 30 10 20
Enter the value of voltage: 2.0

Voltage = 2.0 V
Equivalent resistance = 36.666666 ohm
Current = 0.05454545 A

the underlined values are to be entered by the user (meaning i enter 30 10 20 for the 3 resistances).

ok problem lies at the "entering values of 3 resistances" and the printf & scanf for that part. the output after compiling it is different from the supposed output, after i enter the 3 resistances 30 10 20.
Can you paste the screen shot for you desired output
and Output you are obtaining
It seems like a logical error
You must mention your desired output form
Any Test DATA or Values
Reference URL's