{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Unit Test 2 - #include<stdio.h>#include<math.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 Document Right 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 <stdio.h> #include <math.h> int main(void) { float fPotentialE1; float fPotentialE2; float fmass = 8.0; float fgravity = 9.8; float fheight1; float fheight2; printf("Please input the first height:"); scanf("%f", &fheight1); printf("Please input the second height:"); scanf("%f", &fheight2); fPotentialE1 = fmass*fgravity*fheight1; fPotentialE2 = fmass*fgravity*fheight2; if(fPotentialE1>fPotentialE2) printf(“The first height yields a higher Potential Energy:%10.3f”,fPotentialE1); else if(fPotentialE2>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

{[ snackBarMessage ]}