1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sophie [7]
2 years ago
12

Do not use C++ pointers (this is not a topic of this course).

Engineering
1 answer:
noname [10]2 years ago
4 0

The program is an illustration of functions in C++

C++ functions are collection of named program statements that are executed when called

<h3>The C++ program</h3>

The program in C++, where comments are used to explain each action is as follows:

#include <iostream>

#include <cmath>

using namespace std;

//This defines the boolean method

bool isoscelesTriangleHeightAndArea(double base, double hypotenuse, double height, double area) {

   //This checks for invalid base and height

   if(base < 0 || hypotenuse < 0){

       return false;

   }

   //This returns true if base and height are valid

   return true;

}

//The main begins here

int main(){

   //This initializes the variables

   double base, hypotenuse, height, area;

   //This gets input for base and hypotenuse

   cout<<"Base: ";    cin>>base;

   cout<<"Hypotenuse: "; cin>>hypotenuse;

   //The calls the boolean method

   bool success = isoscelesTriangleHeightAndArea(base, hypotenuse, height, area);

   //If success is True

   while (success){

       //This calculates height

       height = sqrt(hypotenuse*hypotenuse - (base/2) * (base/2));

       //This calculates area

       area = 0.5 * base * height;

       //This prints height

       cout << "Triangle height is " << height << endl;

       //This prints area

       cout << "Triangle area is " << area << endl;

       //This gets input for base and hypotenuse

       cout<<"Base: ";    cin>>base;

       cout<<"Hypotenuse: "; cin>>hypotenuse;

       bool success = isoscelesTriangleHeightAndArea(base, hypotenuse, height, area);

   }

   cout << "Invalid Input!" << endl;

}

Read more about C++ programs at:

brainly.com/question/24833629

#SPJ1

You might be interested in
Consider a Carnot heat-engine cycle executed in a closed system using 0.028 kg of steam as the working fluid. It is known that t
Paha777 [63]

Answer:

T=138 °C

Explanation:

Given that

m = 0.028 kg

Net work output W= 60 KJ

T₂=2T₁

As we know that efficiency of Carnot heat engine given as

\eta=1-\dfrac{T_1}{T_2}

\eta=1-\dfrac{T_1}{2T_1}

η = 0.5

We know that

\eta=\dfrac{W}{Q_a}

Qa=heat addition

W= net work output

\eta=\dfrac{W}{Q_a}

0.5=\dfrac{60}{Q_a}

Qa= 120 KJ

From first law

Qa= W+ Qr

Qr= 120 - 60

Qr= 60 KJ  

Qr Is the heat rejection.

Heat rejection per unit mass

Qr=60 / 0.028 = 2142.85 KJ/kg

Qr= 2142.85 KJ/kg

Temperature at which latent heat of steam is  2142.85 KJ/kg will be our answer.

T=138 °C

The temperature corresponding to 2142.85 KJ/kg will be 138 °C.

T=138 °C

8 0
3 years ago
Air in a large tank at 300C and 400kPa, flows through a converging diverging nozzle with throat diameter 2cm. It exits smoothly
-Dominant- [34]

Answer:

The answer is "3.74 \ cm\ \ and \ \ 0.186 \frac{kg}{s}"

Explanation:

Given data:  

Initial temperature of tank T_1 = 300^{\circ}\ C= 573 K

Initial pressure of tank P_1= 400 \ kPa

Diameter of throat d* = 2 \ cm

Mach number at exit M = 2.8

In point a:

calculating the throat area:

A*=\frac{\pi}{4} \times d^2

      =\frac{\pi}{4} \times 2^2\\\\=\frac{\pi}{4} \times 4\\\\=3.14 \ cm^2

Since, the Mach number at throat is approximately half the Mach number at exit.  

Calculate the Mach number at throat.  

M*=\frac{M}{2}\\\\=\frac{2.8}{2}\\\\=1.4

Calculate the exit area using isentropic flow equation.

\frac{A}{A*}= (\frac{\gamma -1}{2})^{\frac{\gamma +1}{2(\gamma -1)}}  (\frac{1+\frac{\gamma -1}{2} M*^2}{M*})^{\frac{\gamma +1}{2(\gamma -1)}}

Here: \gamma is the specific heat ratio. Substitute the values in above equation.

\frac{A}{3.14}= (\frac{1.4-1}{2})^{-\frac{1.4+1}{2(1.4 -1)}}  (\frac{1+\frac{1.4-1}{2} (1.4)^2}{1.4})^{\frac{1.4+1}{2(1.4-1)}} \\\\A=\frac{\pi}{4}d^2 \\\\10.99=\frac{\pi}{4}d^2 \\\\d = 3.74 \ cm

exit diameter is 3.74 cm

In point b:

Calculate the temperature at throat.

\frac{T*}{T}=(1+\frac{\Gamma-1}{2} M*^2)^{-1}\\\\\frac{T*}{573}=(1+\frac{1.4-1}{2} (1.4)^2)^{-1}\\\\T*=411.41 \ K

Calculate the velocity at exit.  

V*=M*\sqrt{ \gamma R T*}

Here: R is the gas constant.  

V*=1.4 \times \sqrt{1.4 \times 287 \times 411.41}\\\\=569.21 \ \frac{m}{s}

Calculate the density of air at inlet

\rho_1 =\frac{P_1}{RT_1}\\\\=\frac{400}{ 0.287 \times 573}\\\\=2.43\  \frac{kg}{m^3}

Calculate the density of air at throat using isentropic flow equation.  

\frac{\rho}{\rho_1}=(1+\frac{\Gamma -1}{2} M*^2)^{-\frac{1}{\Gamma -1}} \\\\\frac{\rho *}{2.43}=(1+\frac{1.4-1}{2} (1.4)*^2)^{-\frac{1}{1.4-1}} \\\\\rho*= 1.045 \ \frac{kg}{m^3}

Calculate the mass flow rate.  

m= \rho* \times A* \times V*\\\\= 1.045 \times 3.14 times 10^{-4} \times 569.21\\\\= 0.186 \frac{kg}{s}

5 0
3 years ago
Ethylene glycol, the ingredient in antifreeze, does not cause health problems because it is a clear liquid.
netineya [11]
B. false

Explanation: because it is
5 0
3 years ago
Please help this is due today!!!!!
White raven [17]

Answer:

1:c 2:False

Explanation:

7 0
3 years ago
In c the square root of a number N can be approximated by repeated calculation using the formula NG = 0.5(LG + N/LG) where NG st
DanielleElmas [232]

Answer:

Following are the program to the given question:

#include <stdio.h>//header file

double square_root(double N, double initialGuess)//defining a method square_root that takes two variable in parameters

{

double NG, LG = initialGuess,diff;//defining double variable

while(1)//use loop to calculate square root value

{

NG = 0.5 * (LG + N / LG);//using given formula

diff = NG - LG;//calculating difference

if(diff < 0)//use if to check difference is less than 0

diff = -diff;//decreaing difference

if(diff < 0.005)//use if that check difference is less than 0.005

break;//using break keyword  

else//defining else block

{

LG = NG;//holding value

}

}

return NG;//return value

}

int main()//defining main method

{

double ans, n,initialguess = 1.0;//defining double variable

n = 4;//use n to hold value

ans = square_root(n, initialguess);//calculating the square root value and print its value

printf("square_root(%lf) = %lf \n", n, ans);//print calculated value with number

n = 120.5;//use n to hold value

ans = square_root(n, initialguess);//calculating the square root value and print its value

printf("square_root(%lf) = %lf \n", n, ans);//print calculated value with number

n = 36.01;//use n to hold value

ans = square_root(n, initialguess);//calculating the square root value and print its value

printf("square_root(%lf) = %lf \n", n, ans);//print calculated value with number

n = 0.25;//use n to hold value

ans = square_root(n, initialguess);//calculating the square root value and print its value

printf("square_root(%lf) = %lf \n", n, ans);//print calculated value with number

printf("\nEnter a number: ");//print message

scanf("%lf", &n);//input value

ans = square_root(n, initialguess);//calculating the square root value and print its value

printf("square_root(%lf) = %lf \n", n, ans);//print calculated value with number

}

Output:

Please find the attachment file.

Explanation:

  • In this code, a method "square_root" is declared that takes two variable "N, initialGuess" in its parameters, inside the method a three double variable is declared.
  • It uses the given formula and uses the diff variable to hold its value and uses two if to check its value is less than 0 and 0.005 and return its calculated value.
  • In the main method, three double variables are declared that use the "n" to hold value and "ans" to call the method that holds its value and print its value.

8 0
3 years ago
Other questions:
  • Consider a 2-shell-passes and 8-tube-passes shell-and-tube heat exchanger. What is the primary reason for using many tube passes
    6·1 answer
  • Which of the following statement(s) are true?
    14·1 answer
  • A 15. μF capacitor is connected to a 50. V battery and becomes fully charged. The battery is removed and a slab of dielectric th
    10·1 answer
  • In a 1-phase UPS, Vd = 350 V, vo(t) = 170 sin(2π * 60t) V, and io(t) = 10 sin(2π * 60t - 30ᴼ) A.Calculate and plot da(t), db(t),
    14·1 answer
  • Discuss the effect of PRE and CLR in JK flip-flop.​
    8·1 answer
  • A police officer in a patrol car parked in a 70 km/h speed zone observes a passing automobile traveling at a slow, constant spee
    6·1 answer
  • You have been asked to design a steady state treatment device similar to a continuously mixed reactor to treat toluene in an aqu
    11·1 answer
  • What Is the Job Demand for Solar Engineers?<br> (2 or more sentences please and thank you)
    9·1 answer
  • Which option distinguishes what can be inferred from the following scenario?
    14·1 answer
  • A(n) ____ combines two planetary gearsets to provide more gear ratio possibilities. A)compound planetary gearset B)orifice C)det
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!