{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cps 196 week 4

cps 196 week 4 - Integer and Floating point conversions int...

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

Integer and Floating point conversions int to float and float to int 5 5.0 5.19 5 type casting force an integer to be floating point number (and vice versa) change result to floating point variable force value 2 to be floating point, so result is floating point Assignment operator format: op= operator can be +,-,*,/, % count += 10; same as count = count+10; count -=5; count=count-5 a /=b+c a=a/ b+c a/= a/(b+c) use a lot (especially in loops) i++; i=i+1; i--; i=i-1; int i=1 Loop - some problems may require us to preform some routine/procedure over and over. 6x1=6 –-> Printf(“%i x 1 = %i\n”, value1, value1*1); 6x2= printf(%i x 2 = %i\n”, value1, value 1*2); 6x3= 6x4= 6x5= 6x6= 6x7= 6x8= 6x9== 6x10= 6x11= 6x12= 72

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

View Full Document
^^^^^not efficient^^^^^ Loop statement 1 “for statement” for (initial expression; loop condition; loop experession) (NO SEMI COLON) { …loop body } o initial expression is used to set the initial values before the loop begins o loop condition the loop continue as long as this condition is satisfied. o relational expression ==

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 ]}