Hey guys, so I have been acing all my programs so far and getting perfect scores but I have a couple of questions.
I am having my first C++ test tomorrow and it will include programming, writing sophisticated equations if you were doing it through an input, and solving problems like a compiler (int/double).
I feel as though I have my program skills set for this test but my main question is for the other 2.
1. In regards to writing sophisticated equations do you guys have any tips?
Side Question:lets say you had e^3^t(rare case but I'm curious) would it be written as " exp(3,t); " are you able to add a comma showing that it is to be a power of 3? Or could you declare 3^t by doing double blah = pow(3,t) and then doing exp(blah).
2. When it comes to solving problems like a compiler I am completely confused. I am sure in some early C++ courses you guys have had problems like these. Where you are meant to find the answer even though there are a bunch of int's and doubles in the actual equation:
For example:
3/5 * (1.25-2) + 4/3 * (2-(4*2)) + exp(3/5) + 3/4.
Integer answer = -4 double answer = -4.25
If this was given, what would be considered the correct answer?
--- One last question, my latest program I have been working with
cin
1 2 3 4 5 6 7 8 9 10 11 12 13
|
double degrees, wavelength, wavelengthE, wavelengthS, wavelengthM, kelvin, mars;
int sun, earth;
sun=5727;
earth=14;
mars=0.46;
const int WEINCONSTANT= 2897; // the units for wein's constant is microns/Kelvins
kelvin=273.15; // For Converting Celcius to Kelvin
output<<"Please Insert Degrees In Celcius to calculate the Maximum Wavelength:"<< endl;
cout<<"Please Insert Degrees In Celcius to calculate the Maximum Wavelength:"<< endl;
cin >> degrees;
wavelength= WEINCONSTANT / (degrees+kelvin);
output<<"\nThe Maximum Wavelength is = " <<wavelength<< " at "<<degrees<<" Degrees Celcius"<<endl;
cout<<"\nThe Maximum Wavelength is = " <<wavelength<< " at "<<degrees<<" Degrees Celcius"<<endl;
|
Assuming I have 5 different values I want to enter. Instead of inserting one, getting the answer, and then restarting the program.. how can I make it so that after getting an answer, I can ask:
"If you want to try another value please type 1, if not type 0"
If you press 1, it will go through the program again.
Is that possible without doing something like if's or for loops (haven't gotten there yet so I want to avoid it) or are if's and for loops the only way?
Thanks in advance guys, I know its a lot to answer and sorry for grammatical errors typing from college before I leave!