IA_Supplemental_Instruction_1

IA_Supplemental_Instruction_1 - IA Supplemental Instruction...

Info iconThis preview shows pages 1–12. 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

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: IA Supplemental Instruction Justine Kunz Supplemental Instruction Basic Info Reinforces concepts learned in lecture Allows more time for you to ask questions Allows us to see what concepts you're having issues with Ground Rules: No individual project questions No eating in this room, only bottled water is allowed About us: Im the IA (Instructional Aide). Think of me as the undergrad equivalent of GSI's for this class! How is data sent to/from the caller? Pass-by-value copies the data from the caller to a new location in the algorithm o When pass-by-calue is used to send data back to the caller, it is called a return o The caller can either use this data, or ignore it Pass-by-reference gives direct access to the data in the caller's environment o The caller cannot ignore this data since it is directly changed Reading a C++ Program Programs consist of two parts: Scaffolding holds the program together and provides context for the C+ + compiler Code uses declarations (line 7), and expressions (line 9) to do calculations with identifiers (such as x and y ) 1 #include <iostream> 2 #include <cmath> 3 using namespace std; 4 5 int main() 6 { 7 double x = 3, y; 8 cin >> x; 9 y = x * 5; 10 cout << y; 11 12 return 0; 13 } Scaffolding EXAMPLES cin, cout, and cerr are all part of the < iostream> library pow, sqrt, log10, cos are all functions included in the < cmath> library Remember to include the proper libraries when writing programs! For 101, ALWAYS include the following line after your #include lines and before your main function: using namespace std; Reading a C++ Program: Declaration Simple declarations are of the form: simple_type identifier In this case, the identifiers x and y are declared as doubles. We know of two simple types: double and int o Doubles have fractional values o Ints are integers 1 #include <iostream> 2 #include <cmath> 3 using namespace std; 4 5 int main() 6 { 7 double x = 3, y; 8 cin >> x; 9 y = x * 5; 10 cout << y; 11 12 return 0; 13 } Reading a C++ Program: Expressions Expressions change and exchange data Semicolons denote the end of an expression Braces {} denote a compound statement The braces here denote that lines 6-13 are all part of the main function NOTE: No semicolon is needed at the end of a function declaration (line 5). These are not expressions! 1 #include <iostream> 2 #include <cmath> 3 using namespace std; 4 5 int main() 6 { 7 double x, y; 8 cin >> x; 9 y = x * 5; 10 cout << y; 11 12 return 0; 13 } Exercise: What is the output? int main() { int x = 2, y = 3, z; z = pow( x, y); cout << x << y; cout << endl; cout << z; cout << endl; x += y; cout << x << endl; return 0; } Exercise: What is the output?...
View Full Document

Page1 / 51

IA_Supplemental_Instruction_1 - IA Supplemental Instruction...

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

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