Write a C program that will solve the voltage divider problem: Ask the user for
ID: 1715519 • Letter: W
Question
Write a C program that will solve the voltage divider problem: Ask the user for VI (source voltage) and store the input in a character array. Convert the input string to a double type (call the variable VI, which should be of double type). . Confirm the entry by printing out the double value (i.e. print a response such as "You entered 5.0 volts for VI"). Perform steps 1-3 for R1 and R2 as you did for VI (ask for the two resistance values and confirm the values by printing them out, e.g. "You entered 3 ohms for R1"). Calculate the total current I in the circuit and print a statement that says "The total current in the circuit is I = x.yy amperes". Calculate the output voltage Vout (which should be stored as a double variable named Vout) and print a statement that says "The output voltage is Vout = x.yy volts".Explanation / Answer
#include <stdio.h>
int main()
{
//Declaring float variables input voltages
char Vin,R1,R2;
printf(" Please enter the input voltage ");
scanf("%c",&Vin);
double v = (double)Vin;
printf(" Please enter the R1 ");
scanf("%c",&R1);
double r1 = (double)R1;
printf(" Please enter the R2 ");
scanf("%c",&R2);
double r2 = (double)R2;
float V0;//declaring variable that is being calculated
V0 = (r1*v)/(r1+r2);
printf("The output voltage is %f ",V0);
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.