I managed to write this program, I post here maybe can help others.
Code:
/* C PROGRAMING ASSIGNEMENT 4.10 */
/* Saeid Yazdani */
//Includes
#include <stdio.h>
//Function Definitions
double R_Parallel(double, double); //Function to calculate and return for "nCount" Resistors in parallel
double Uout(double, double, double);
int main() {
double fUin = -1, fRo = -1;
int nCount = 0; // Number of parallel resistors to be entered
int nHelp; //Help variable for using iside for lope in R_Parallel function
double fUout = 0;
// Ask user to input Uin and Ro
while ((fUin < 0) && (fRo < 0)) {
printf("Please input Voltage and Ro, separated by a space:\n");
scanf("%lf %lf", &fUin, &fRo);
}
// Showing the user his/her input values
printf("\nYou have entered Uin as %f, and Ro As %f \n", fUin, fRo);
R_Parallel(fUin, fRo);
return 0;
}
//FUNCTIONS
//Function to ask user for input parallel resistances
double R_Parallel(double fUin, double fRo) {
// Internal variables for function
int nHelp, nCount = 0; // Help and Counter
double fPRE; //Pralaller Resistance Equivelant
double fResistor; //Resistor
double fUout; //Uout is the final output voltage after the voltage divider
while (1) { //WHILE 1
printf("\nPlease input parallel resistant number %d,\ninput a negative value to finish the operation: \n", nCount);
scanf("%lf", &fResistor);
if(fResistor <= 0) { printf("\nStopping the program since a negative value is entered, the last calulated output voltage is %f Volts.", fUout); break;}
nCount++;
// Special case for first entered resistor, it will be in series with Ro
if(nCount == 1) {fPRE = fResistor;}
// Calculating total resistance for more thatn
if(nCount != 1){
fPRE = 1/((1/fPRE)+(1/fResistor));
}
fUout = (fRo/(fRo+fPRE))*fUin;
printf("\nU out is now %f Volts.\n", fUout);
}//END WHILE 1
return (0);
}