unit 3 me 205 - if(fTh<=0) { cout...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 { int R, C /*R-Radius of circle */ float perimeter /*Circumference of circle */ float area /*area of circle */ C = PI R = 5 Perimeter = 2.0 *C *R Area = C*R*R cout >> perimeter, area } #include <iostream> #define pi 3.14159 int main(void) { int iR, C float fP = 0.0 float fA = 0.0 cout <<" #include <iostream> using namespace std int main(void) { int iA=15 int iB=7 int iC=2 iA++ iB = iA%iB --iB cout << iA*iB/iC << endl cout << ((iB < iC) ? iA : iB) << endl cout << ++iA << endl return 0 } #include <iostream> #include <cmath>
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sheet1 Page 2 #define pi 3.14159 using namespace std int main(void) { float f1 = 0.0 float f2 = 0.0 float fTh = 0.0 double dA = 0.0 cout <<"Please enter a value for the first side of the triangle."<< endl cin >> f1 if(f1<=0) { cout <<"Invalid side value, exiting. .."<<endl return 0 } cout <<"Now please enter a value for the second side of the triangle."<< endl cin >> f2 if(f2<=0) { cout <<"Invalid side value, exiting. .."<<endl return 0 } cout <<"Now please enter a valid angle value in radians."<< endl cin >> fTh
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if(fTh&lt;=0) { cout &lt;&lt;&quot;Invalid radian value, exiting. ..&quot;&lt;&lt;endl return 0 } if(fTh&gt;=2*pi) { cout &lt;&lt;&quot;Invalid radian value, exiting. ..&quot;&lt;&lt;endl return 0 } dA = (.5)*f1*f2*sin(fTh) cout &lt;&lt;&quot;The area of your triangle is: &quot; &lt;&lt; dA &lt;&lt; endl return 0 } Sheet1 Page 3 #include &lt;iostream&gt; #include &lt;cmath&gt; using namespace std int main(void) { float fA, fB, fC, fS, fArea = 0.0 cout&lt;&lt;&quot;Please enter a value for the first side of the triangle.&quot;&lt;&lt;endl cin &gt;&gt; fA if(fA&lt;=0) { cout&lt;&lt;&quot;Invalid input, exiting. ..&quot;&lt;&lt;endl return 0 } cout &lt;&lt;&quot;Please enter a value for the second side of the triangle.&quot;&lt;&lt;endl cin &gt;&gt; fB if(fB&lt;=0) { cout&lt;&lt;&quot;Invalid input, exiting. ..&quot;&lt;&lt;endl return 0 } cout &lt;&lt;&quot;Please enter a value for the third side of the triangle.&quot;&lt;&lt;endl cin &gt;&gt; fC if(fC&lt;=0) { cout&lt;&lt;&quot;Invalid input, exiting. ..&quot;&lt;&lt;endl return 0 } fS = (fA+fB+fC)/2 fArea = sqrt(fS*(fS-fA)*(fS-fB)*(fS-fC)) cout &lt;&lt;&quot;The area of the triangle is: &quot; &lt;&lt; fArea &lt;&lt;endl return 0 }...
View Full Document

This note was uploaded on 04/13/2010 for the course ME me205 taught by Professor Pryor during the Spring '09 term at University of Texas-Tyler.

Page1 / 3

unit 3 me 205 - if(fTh&amp;amp;lt;=0) { cout...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online