Exam2_review - CGS 2425 C Exam 2 Review VARIABLES Variables...

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

View Full Document Right Arrow Icon
CGS 2425 C++ - Exam 2 Review VARIABLES Variables MUST be declared before using them!!!! Always!!! Variables MUST be given values before using them. For example, if you are adding numbers into a variable, the variable MUST be set to some initial value beforehand. SCOPE “Scope” refers to where a variable exists in the code. Local variables exist only in the function (or control structure) in which they are declared. This allows variables with the same names to exist in separate functions without conflict. Global variables exist everywhere. They are declared outside the main function, and can be seen by all functions. There must no variables anywhere with the same name as a global variable. It is STRONGLY recommended that you NEVER use global variables!!! ORDER OF OPERATIONS Pre-increments ( e.g ., ++i ) are performed BEFORE any part of the statement is executed. Post-increments ( e.g ., i++ ) are performed AFTER the entire statement is executed. FUNCTIONS Prototype (before main ): return_type funName( var_type varName, var_type varName, . ..); Implementation (after end of main ): return_type funName( var_type varName, var_type varName, . ..) { // statements return returnValue; // only if return_type is not void } Function call : variable = funName(var1, var2, . ..); // if return type is not void funName(var1, var2, . ..); // if return type is void
Background image of page 1

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

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

This note was uploaded on 09/05/2011 for the course CGS 2421 taught by Professor Onal during the Fall '09 term at University of Florida.

Page1 / 3

Exam2_review - CGS 2425 C Exam 2 Review VARIABLES Variables...

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

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