# cp_1_lect_21 - Assigning values to variables main...

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

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

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

View Full Document
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
Operators Continued… Operator Meaning < Is less than

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.

{[ snackBarMessage ]}

### Page1 / 8

cp_1_lect_21 - Assigning values to variables main...

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

View Full Document
Ask a homework question - tutors are online