cp_1_lect_21 - 5/10/10 Assigning values to variables main()...

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

View Full Document Right Arrow Icon
5/10/10 Assigning values to variables variable_name = constant main() { float x, p ; double y, q ; unsigned k ; int m = 54321 ; long int n = 1234567890 ; x = 1.234567890000 ; y = 9.87654321 ; k = 54321 ; p = q = 1.0 ; printf("m = %d\n", m) ; printf("n = %ld\n", n) ; printf("x = %.12lf\n", x) ; printf("x = %f\n", x) ; printf("y = %.12lf\n",y) ; printf("y = %lf\n", y) ; printf("k = %u p = %f q = %.12lf\n", k, p, q) ; } Output m = -11215 n = 1234567890 x = 1.234567880630 x = 1.234568 y = 9.876543210000 y = 9.876543 k = 54321 p = 1.000000 q = 1.000000000000
Background image of page 1

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

View Full DocumentRight Arrow Icon
Operators Operator Meaning + Addition or unary plus - Subtraction or unary minus * Multiplication / Division % Modulo Division x-y = 9 x+y = 21 x*y = 90 x/y = 2 x%y = 3 Example: Let x = 15 and y = 6 Operator % cannot be used with real operands Que: Let a=-11, and b=-3, find out a / b and a % b Ans: 3, and -2 Let x=-.66 and y=4.5, x/y =-0.14666 Arithmetic 15/10.0=1.5 Mixed mode
Background image of page 2
Operators Continued… Operator Meaning < Is less than
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

cp_1_lect_21 - 5/10/10 Assigning values to variables main()...

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

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