Ohm\'s law for a steady electrical current can be written as V = IR where V = po
ID: 674070 • Letter: O
Question
Ohm's law for a steady electrical current can be written as V = IR where V = potential difference across a conductor I=current in the conductor R=resistance of the conductor Write a program capable of filling in the blanks in the following table: Input specifications. The input data should come from the keyboard and be treated as real numbers. You should prompt the user in the following manner: "For case 1,enter the voltage and current." "For case 2, enter the current and resistance." "For case 3, enter the voltage and resistance." Output specifications. Print the completed table to the screen.Explanation / Answer
#include<stdio.h>
#include<conio.h>
int main()
{
char ch;
float voltage , current , resistance , result;
printf("Ohms law calculator. ");
printf("Please choose from following calculcations. ");
printf("1. choose 1 to calculate the voltage. ");
printf("2. choose 2 to calculate the current. ");
printf("3. choose 3 to calculate the resistance. ");
printf("Anything else to quit. ");
scanf("%c",&ch);
switch(ch)
{
case '1' :
printf("please enter the current in amps. ");
scanf("%f",¤t);
printf("Now enter the resistance in ohms. ");
scanf("%f",&resistance);
result = current * resistance;
printf("The voltage is %0.2f volts. ",result);
break;
case '2' :
printf("please enter the voltage in volts. ");
scanf("%f",&voltage);
printf("Now enter the resistance in ohms. ");
scanf("%f",&resistance);
result = voltage / resistance;
printf("The current is %0.2f amps. ",result);
break;
case '3' :
printf("please enter the voltage in volts. ");
scanf("%f",&voltage);
printf("Now enter the current in amps. ");
scanf("%f",¤t);
result = voltage / current;
printf("The resistance is %0.2f ohms. ",result);
break;
default :
exit(0);
break;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.