Unit Test 2 - #include <stdio.h>...

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

View Full Document Right Arrow Icon
Unit 2 Readiness Test B 1. #include <stdio.h> #include <math.h> int main(void) { float fYears; float fPrinciple; float fSI; float fRate; printf("Please input the Principle:"); scanf("%f", &fPrinciple); printf("Please input the Simple Interest:"); scanf("%f", &fSI); printf("Please input the rate:"); scanf("%f", &fRate); fYears = 100*fSI/fPrinciple/fRate; printf("It will take you %f years to repay the loan",fYears); return(0); } 2. the code should read: #include <stdio.h> #include <math.h> int main(void) { float fTemp_Celc; float fTemp_Fahr; printf(“Please enter the temperature in Celcius:”); scanf("%f", &fTemp_Celc); fTemp_Fahr=(9.0/5.0)*fTemp_Celc+32; printf("\n\n The temperature in Fahrenheit is %8.3f", fTemp_Fahr); return (0); } 3. (214) 8 in decimal is equal to 140 4.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #include &lt;stdio.h&gt; #include &lt;math.h&gt; int main(void) { float fPotentialE1; float fPotentialE2; float fmass = 8.0; float fgravity = 9.8; float fheight1; float fheight2; printf(&quot;Please input the first height:&quot;); scanf(&quot;%f&quot;, &amp;fheight1); printf(&quot;Please input the second height:&quot;); scanf(&quot;%f&quot;, &amp;fheight2); fPotentialE1 = fmass*fgravity*fheight1; fPotentialE2 = fmass*fgravity*fheight2; if(fPotentialE1&gt;fPotentialE2) printf(The first height yields a higher Potential Energy:%10.3f,fPotentialE1); else if(fPotentialE2&gt;fPotentialE1) printf(The second height yields a higher Potential Energy:%10.3f,fPotentialE2); else printf(The two balls have the same Potential Energy:%10.3f,fPotentialE1); return(0); }...
View Full Document

Page1 / 2

Unit Test 2 - #include &amp;amp;lt;stdio.h&amp;amp;gt;...

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

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