Task 2 The relationship between the voltage applied across a resistor and the current flowing through the resistor is given by Ohm's law, which can be expressed in the following mathematical form: V = I× R Where: • V is the voltage across the resistor (volts), V R • I is the current flowing through the resistor (amperes), • R is the resistance (ohms). The following table gives data for the current flowing through a resistor: S. No. Current 1 2 3 4 5 6 7 8 9 10 0.1 0.2 0.5 1.0 1.5 2.0 3.0 5.0 7.5 10.0 (Amperes) a) Write a script that will prompt the user for the value of the resistance and determine the voltage across the resistor for each current in the table. The script will print the result for each current in the following tabular format: Example: S.No. Current (Amperes) Voltage (Volts) 1. 0.1 1.0 2. 0.5 2.0 . 10. 10.0 100.0 b) Plot Voltage vs Current for the given resistance. c) Prompt the user a second time for a different value of resistance and plot the voltage vs current in the same graph as in part (b) for both resistances. (Hint: Use the subplot command and don't forget to label your graphs)
Task 2 The relationship between the voltage applied across a resistor and the current flowing through the resistor is given by Ohm's law, which can be expressed in the following mathematical form: V = I× R Where: • V is the voltage across the resistor (volts), V R • I is the current flowing through the resistor (amperes), • R is the resistance (ohms). The following table gives data for the current flowing through a resistor: S. No. Current 1 2 3 4 5 6 7 8 9 10 0.1 0.2 0.5 1.0 1.5 2.0 3.0 5.0 7.5 10.0 (Amperes) a) Write a script that will prompt the user for the value of the resistance and determine the voltage across the resistor for each current in the table. The script will print the result for each current in the following tabular format: Example: S.No. Current (Amperes) Voltage (Volts) 1. 0.1 1.0 2. 0.5 2.0 . 10. 10.0 100.0 b) Plot Voltage vs Current for the given resistance. c) Prompt the user a second time for a different value of resistance and plot the voltage vs current in the same graph as in part (b) for both resistances. (Hint: Use the subplot command and don't forget to label your graphs)
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section: Chapter Questions
Problem 14PP
Related questions
Question
MATLAB Please don't use AI provide screen shot for output and code Quickly
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning