Write a program to illustrate the Ohm's Law, I=V/R. The program will first request to input an initial voltage (in volt), a fixed resistance (in ohm) and an incremental interval for voltage. A function should be written which will return the value of current (in amp) given a voltage and a resistance. Then the program will call the function and print out a table that shows the value of current under each increment of voltage. The maximum voltage is set to 50 volts. a) main () should handle all input and output. (This requires that variables in main are updated by the function.) b) Secondary function should handle all calculations. c) Set precision to 2. Example Output Enter the initial voltage (up to 50 in volt): 40 Enter the resistance (in ohm): 10 Enter the voltage incremental interval (in volt) : 2 Voltage (volt) Resistance (ohm) Current (amp) 40 10 4.00 42 10 4.20 44 10 4.40 46 10 4.60 48 10 4.80 50 10 5.00

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 22PE
icon
Related questions
Question
3.
Write a program to illustrate the Ohm' s Law, I=V/R. The program will
first request to input an initial voltage (in volt), a fixed resistance
(in ohm) and an incremental interval for voltage. A function should be
written which will return the value of current (in amp) given a voltage
Then the program will call the function and print
out a table that shows the value of current under each increment of
and a resistance.
voltage. The maximum voltage is set to 50 volts.
a) main () should handle all input and output.
(This requires that variables in main are updated by the function.)
b) Secondary function should handle all calculations.
c) Set precision to 2.
Example Output
Enter the initial voltage (up to 50 in volt): 40
Enter the resistance (in ohm) : 10
Enter the voltage incremental interval (in volt): 2
Voltage (volt)
Resistance (ohm)
Current (amp)
40
10
4.00
42
10
4.20
44
10
4.40
46
10
4.60
48
10
4.80
50
10
5.00
Transcribed Image Text:3. Write a program to illustrate the Ohm' s Law, I=V/R. The program will first request to input an initial voltage (in volt), a fixed resistance (in ohm) and an incremental interval for voltage. A function should be written which will return the value of current (in amp) given a voltage Then the program will call the function and print out a table that shows the value of current under each increment of and a resistance. voltage. The maximum voltage is set to 50 volts. a) main () should handle all input and output. (This requires that variables in main are updated by the function.) b) Secondary function should handle all calculations. c) Set precision to 2. Example Output Enter the initial voltage (up to 50 in volt): 40 Enter the resistance (in ohm) : 10 Enter the voltage incremental interval (in volt): 2 Voltage (volt) Resistance (ohm) Current (amp) 40 10 4.00 42 10 4.20 44 10 4.40 46 10 4.60 48 10 4.80 50 10 5.00
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr