{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CS110_02b_mathOps

# 1 given numbers make a new truefalse examples 10 20

This preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: e a new true/false Examples: 1.0 > 2.0, 5<10, 7.00001 >= 7.0, ... Logical (&&,||,...) (later in book: section 5.1) given true/false(s), make a new true/false Examples? TRUE && TRUE, FALSE || TRUE, TRUE && FALSE, FALSE || FALSE 4 Arithmetic Operators For all of math, C has just 5 basic, built-in arithmetic operators: (look for the fancy math functions (sin,cos,log, etc.) in libraries--math.h) + * / % Add Subtract, or negate Multiply Divide Modulus ! ew N 5 A New Arithmetic Operator: % % computes the remainder after the first operand is divided by the second. Examples: (5 % 2) is 1, and (6 % 3) is 0 Useful for making cycles of numbers: For an int variable `x', if x is: (x%4)is: 0 0 1 1 2 2 3 3 4 0 5 1 6 2 7 3 8 0 9 1 10 ... 2 .....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online