filmov
tv
C++ programming to swap two numbers with temp local variable

Показать описание
Swapping Numeric Values
Example program (next slide) takes in two integers, swaps them if first is greater, and then prints out lower number, followed by higher number
Uses single-alternative selection structure with statement block in true path
Creates temporary variable to accomplish swap
Temp variable can only be used in statement block in which it is declared; called a local variable
Example program (next slide) takes in two integers, swaps them if first is greater, and then prints out lower number, followed by higher number
Uses single-alternative selection structure with statement block in true path
Creates temporary variable to accomplish swap
Temp variable can only be used in statement block in which it is declared; called a local variable