while - while Loops Programming P102 Prog Fundamentals I:...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: while Loops Programming P102 Prog Fundamentals I: while Loops/Slide 2 Shortcut Assignments C++ has a set of shortcut operators for applying an operation to a variable and then storing the result back into that variable. Shortcut assignments (a and b are integers): shortcut same as *= a *= b; a = a*b; /= a /= b; a = a/b; += a += b; a = a+b;-= a -= b; a = a-b; %= a %= b; a = a%b; P102 Prog Fundamentals I: while Loops/Slide 3 Shortcut Assignments Examples int i = 3; i += 4; // i = i + 4 cout << i << endl; // i is now 7 double a = 3.2; a *= 2.0; // a = a * 2.0 cout << a << endl; // a is now 6.4 int change = 1265; change %= 100; // change = change % 100 cout << change << endl; // change is now 65 P102 Prog Fundamentals I: while Loops/Slide 4 Loops (Iterative Constructs) Loops allow a code segment to be executed many times. Three constructs while statement for statement do- while statement P102 Prog Fundamentals I: while Loops/Slide 5 The while Statement Syntax...
View Full Document

Page1 / 13

while - while Loops Programming P102 Prog Fundamentals I:...

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

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