The question is to write a program that will input resistance R, current I for serval resistors, and will calculate and display the voltage for each resistor. The loop will terminate if your enter -1 as the resistance value. (Note that your program should output nothing when -1 is entered as the resistance value)Code:float i, R, I; // counter, resistance, input// float V; // voltage// printf("Enter the current: "); scanf("%f",&I); while ( R != -1) { printf("Enter the resistance: " ); scanf("%f",&R); V= R * I; printf("Voltage is %f\n", V); } return 0;
I want it to do nothing when I enter -1 for resistance but for this one it calculates the voltage. So what should i do?