- #1
JJ452
- 3
- 0
Hi,
I have to build a program that will find the equivalent resistances in series and parallel of any number of resistances entered at the keyboard. So far i have this:
I really don't know where i went wrong. The value returned for RTS is the same value as the user entered and the value returned for RTP is the last value for the resistor entered. I reckon it's a problem with the loop but what it is i don't know. Help please?
I have to build a program that will find the equivalent resistances in series and parallel of any number of resistances entered at the keyboard. So far i have this:
/*
TITLE- q4__4.c 2/10/06
DESCRIPTION- Calculates the effective resistance of a entered number of resistors in series and in parallel
*/
/* Include standard input ouput library */
#include <stdio.h>
main()
{
/* local variables go here */
double RTS,RTP,LOOPS,X,loop_count;
/* The Number of Resistors */
printf("How many resistors would you like to calculate a value for?");
scanf("%lf",&LOOPS);
/* The loop statement */
loop_count=0;
RTS=0;
RTP=0;
do
{
printf ("Enter a value for resistance >");
scanf("%lf",&X);
RTS += X;
RTP += (1/X);
loop_count = (loop_count + 1);
}while (loop_count < LOOPS);
/* The Result */
printf ("\nThe Total resistance is %lf if they are in series and %lf they are in parallel."),RTS,(1/RTP);
I really don't know where i went wrong. The value returned for RTS is the same value as the user entered and the value returned for RTP is the last value for the resistor entered. I reckon it's a problem with the loop but what it is i don't know. Help please?