Hello,
I'm working on a program to calculate the total resistor of a network of resistors. In this program I have to ask the user how many resistors are serial and how many are parallel. Until that part it goes quite well, but I'm having trouble with the part where I connect the answer of the user to how often the program goes through my loop.
I tried to make it work with a for and a while loop but I can't figure it out.
Code:
//Programma voor het berekenen van de vervangingsweerstand van een laddernetwerk van weerstanden.#include <stdio.h>
#include <math.h>
float Rvserial;
float Rvparallel;
float Rs, Rp;
float totalserial, totalparallel;
void main(void)
{
printf("In this program will calculate the total resistor of your network\n");
printf("How many serialresistors do you have?\t");
scanf("%f", &totalserial);
printf("How many prallelresistors do you have?\t");
scanf("%f", &totalparallel);
while (Rs >= 0) {
printf("Enter your values of the serial resistors. Negative value is stop\n");
printf("Give the value in ohms\t\t");
scanf("%f", &Rs);
if (Rs >= 0) {
Rvserial = Rvserial + Rs;
}
}
printf("Enter your values of the parallel resistors. Negativ value is stop.\n");
printf("Give the value in ohms \t\t");
scanf("%f", &Rp);
if (Rp >= 0){
Rvparallel =
This is what I have for now. As you can see it is far from finished and I have certain things with no use in combination with other lines, but that is just my mind at the moment.
I hope someone can give me a clear vision.