You’ve been asked to write a C++ program to calculate the total resistance of a
ID: 3664287 • Letter: Y
Question
You’ve been asked to write a C++ program to calculate the total resistance of a series circuit. In this circuit, the total resistance is the sum of all individual resistance values. The circuit consists of a number of 56-ohm, 33-ohm, and 15-ohm resistors. a. For this programming problem, how many outputs are required? b. How many inputs does this problem have? c. Determine a formula for converting input items into output items. The number of 56-ohm resistors is m, the number of 33-ohm resistors is n, and the number of 15-ohm resistors is p. d. Test the formula written for Exercise 1c using the following sample data: m = 17, n = 24, and p = 12.
Explanation / Answer
The output will be resistance.
The inputs will be 3 which are m,n,p
m=number of 56 ohm resistors
n=number of 33 ohm resistors
p=number of 15 ohm resistors.
=>total resistance=(m*56+n*33+p*15) ohms
The program is
int main()
{ int m,n,p;
int totalresistance;
cout<<"enter m,n p";
cin>>m>>n>>p;
totalresistance=m*56+n*33+p*15;
cout<<totalresistance;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.