code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
Terms of Agreement:
By using this code, you agree to the following terms...
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
/*
Author:Wilton Marranzini
Objective: this program is designed to compute a value of pressure ratio (Pt/P0)
INPUT: mach number from user & a const declaration of GAMMA = 1.4.
OUTPUT: Will be the Pressure Ratio.
FORMULA: mach_ans= pow(mach,2)
division= (GAMMA-1)/2
equation= (mach_ans*division)+1
power= (GAMMA)/(GAMMA-1)
answer = Pow(equation,power)
ALGORITHM: 1- Obtain mach number from user.
2- compute a value of pressure ratio (Pt/P0).
3- Display answer as a ratio.
______________________________________________________________________________
*/
#include
#include
int main() //main function.
{ const float GAMMA = 1.4; //Declaring constant value for GAMMA.
float mach;//The mach number that the user will Input.
float mach_ans;//Answer after mach is squared.
float division;//Doing the division of the equation.
float equation;//Solving for the whole equation.
float power;//Is the variable equation is raised to.
float answer; //Answer of the problem.
int screen; //Keeps screen open.
cout << "Enter the Mach number please.\n";
cin >> mach;//Storing data on variable mach.
//start of the formula.
mach_ans = pow(mach,2);
division = (GAMMA-1)/2;
equation = (mach_ans*division)+1;
power= (GAMMA)/(GAMMA-1);
answer= pow(equation,power);
//End of the formula.
cout << "Your answer is " << answer << ".\n";
cin >> screen;
return 0; //Returning a value
}