review 1 version F ee3aeR

# review 1 version F ee3aeR - d printf"Input M\n"...

This preview shows pages 1–6. Sign up to view the full content.

Sheet1 Page 1 1) (110011001)2 to Decimal 1 * 2^0 = 1 0 * 2^1 = 0 0 * 2^2 = 0 1 * 2^3 = 8 1 * 2^4 = 16 0 * 2^5 = 0 0 * 2^6 = 0 1 * 2^7 = 128 1 * 2^8 = 256 -------------- = 409 (12545)8 to Decimal 5 * 8^0 = 5 4 * 8^1 = 32 5 * 8^2 = 256 2 * 8^3 = 1024 1 * 8^4 = 4096 --------------- = 5413 2) A) print out 3.142 exactly? printf("Approximate value of PI = %4.3f\n", PI) What would %15.2f print? 15 digits wide with 2 digits of precision to the right-hand side of the decimal point Approximate value of PI= 3.14 2) B) both statements are right since they make each statment right 2) C) #include <math.h> directive is used to make the compiler scan the header file at the start of the source file. its functions are abs(x), acos(x), asin(x), atan(x). ................. yes you can multiply and divide with out the #include <math.h> header, as long as you have the #include <stdlib.h> header 3)

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

View Full Document
Sheet1 Page 2 #include <stdio.h> #include <math.h> int main(void) { double G = 9.8 float fM, fm, fr double Force

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: d printf ("Input M \n") scanf ("%f", &fM) printf ("Input m \n") scanf ("%f", &fm) printf ("Input r \n") scanf ("%f", &fr) Force = ((G * fM * fm)/ (fr * fr)) printf ("The Force is %lf \n", Force) p Force = ((G * fM * fm)/ (((fr*.5) * (fr*.5)))) printf ("The Second Force is %lf \n", Force) p Force = ((G * fM * fm)/ (((fr *.25) * (fr * .25)))) printf ("The Third Force is %lf \n", Force) getchar() return (0) r } 4) #include <stdio.h> #include <math.h> int main(void) { float fK1, fK2 double Output1 double Output2 printf ("Input K 1 \n") scanf ("%f", &fK1) printf ("Input K 2 \n") scanf ("%f", &fK2) Output1 = (fK1 + fK2) Output2 = ((fK1 * fK2)/(fK1 + fK2)) O if (Output2 > Output1) { printf ("The lowest output 2 is %lf \n", Output1) } Sheet1 Page 3 else if (Output2 == Output1) {printf("same\n") } else{ printf ("The lowest output 1 is %lf \n", Output2) p return 0 } Sheet1 Page 4 Sheet1 Page 5 Sheet1 Page 6 }...
View Full Document

### Page1 / 6

review 1 version F ee3aeR - d printf"Input M\n"...

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

View Full Document
Ask a homework question - tutors are online