(Electrical eng.) a. The voltage gain of an amplifier is given by this formula:
f is the frequency in Hz.
n is the number of stages in the amplifier.
Using this formula, write, compile, and run a C++
At a frequency of xxxxx hertz, the voltage gain is yyyyy
Your program should replace xxxxx with the frequency and yyyyy with the voltage gain.
b. Manually check the value your program produces. After verifying that your program is working correctly, modify it to determine the voltage gain of a 12-stage amplifier operating at a frequency of 9500 Hz.
(a)
Program Plan:
- The variable vgis usedto store the voltage gain
- The variable nis used to storethe number of stages
- The variable fis used to storethe frequency (in Hertz)
- A pre-defined function sqrt() is used to find the square root of an argument given.
- A pre-defined function pow() is used to give a mathematical power to a variable.
Program Description:
The C++ program finds the voltage gain using following formulae:
A formula of a voltage gain is used to find the voltage gain at the stage of four and a frequency of 120 Hz.
Explanation of Solution
Program:
#include <iostream> #include <math.h> using namespace std; int main() { float vg; // voltage gain int n = 4; // number of stages float f = 120; // frequency(Hz) // formula vg = pow((275/(sqrt(pow(23,2)+(0.5*(f * f))))),4); cout <<"At a frequency of "<< f <<" hertz, the voltage gain is "<< vg; return 0; }
Sample Output:
When f = 120 Hz and number of stages = 4
(b)
To check manually if the above program works correctly using the given values.
Explanation of Solution
Given:
Frequency (f) = 120 Hz
Stages (n) = 4
Explanation:
The answer is close to the above output produced by the program.Hence the program is working correctly.
Want to see more full solutions like this?
Chapter 3 Solutions
C++ for Engineers and Scientists
- (General math) The volume of oil stored in an underground 200-foot deep cylindrical tank is determined by measuring the distance from the top of the tank to the surface of the oil. Knowing this distance and the radius of the tank, the volume of oil in the tank can be determined by using this formula: volume=radius2(200distance) Using this information, write, compile, and run a C++ program that accepts the radius and distance measurements, calculates the volume of oil in the tank, and displays the two input values and the calculated volume. Verify the results of your program by doing a hand calculation using the following test data: radius=10feetanddistance=12feet.arrow_forward(General math) a. Design, write, compile, and run a C++ program to calculate the volume of a sphere with a radius, r, of 2 in. The volume is given by this formula: Volume=4r33 b. Manually check the values computed by your program. After verifying that your program is working correctly, modify it to determine the volume of a cube with a radius of 1.67 in.arrow_forward(Practice) Determine the values of the following integer expressions: a.3+46f.202/( 6+3)b.34/6+6g.( 202)/6+3c.23/128/4h.( 202)/( 6+3)d.10( 1+73)i.5020e.202/6+3j.( 10+3)4arrow_forward
- (Physics) a. Design, write, compile, and run a C++ program to calculate the elapsed time it takes to make a 183.67-mile trip. This is the formula for computing elapsed time: elapsedtime=totaldistance/averagespeed The average speed during the trip is 58 mph. b. Manually check the values computed by your program. After verifying that your program is working correctly, modify it to determine the elapsed time it takes to make a 372-mile trip at an average speed of 67 mph.arrow_forward(Physics) a. The weight of an object on Earth is a measurement of the downward force onth e object caused by Earth’s gravity. The formula for this force is determined by using Newton’s Second Law: F=MAeFistheobjectsweight.Mistheobjectsmass.AeistheaccelerationcausedbyEarthsgravity( 32.2ft/se c 2 =9.82m/ s 2 ). Given this information, design, write, compile, and run a C++ program to calculate the weight in lbf of a person having a mass of 4 lbm. Verify the result produced by your program with a hand calculation. b. After verifying that your program is working correctly, use it to determine the weight, on Earth, of a person having a mass of 3.2 lbm.arrow_forward(Practice) State whether the following variable names are valid. If they are invalid, state the reason. prod_a c1234 abcd _c3 12345 newamp watts $total new$al a1b2c3d4 9ab6 sum.of average volts1 finvoltarrow_forward
- (General math) a. Design, write, compile, and run a C++ program that calculates and displays the area of a triangle, such as the one in Figure 2.18, with a base of 1 in and a height of 1.5 in. The area is given by this formula: Area=12(base)(height) b. Manually check the values computed by your program. After verifying that your program is working correctly, modify it to determine the area of a two-dimensional triangle with a base of 3.5 in and a height of 1.45 in.arrow_forward(General math) a. Write a C++ program to calculate and display the value of the slope of the line connecting two points with the coordinates (3,7) and (8,12). Use the fact that the slope between two points with the coordinates (x1,y1)and(x2,y2)is(y2y1)/(x2x1). b. How do you know the result your program produced is correct? c. After verifying the output your program produces, modify it to determine the slope of the line connecting the points (2,10) and (12,6). d. What do you think will happen if you use the points (2,3) and (2,4), which results in a division by zero? How do you think this situation can be handled? e. If your program doesn’t already do so, change its output to this: The value of the slope is xxx.xx The xxx.xx denotes placing the calculated value in a field wide enough for three places to the left of the decimal point and two places to the right of it.arrow_forward(General math) If a 20-foot ladder is placed on the side of a building at an 85-degree angle, as shown in Figure 3.11, the height at which the ladder touches the building can be calculated as height=20sin85. Calculate this height by hand, and then write, compile, and run a C++ program that determines and displays the value of the height. After verifying that your program works correctly, use it to determine the height of a 25-foot ladder placed at an angle of 85 degrees.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr