Cpp_notes_summary_2

# Cpp_notes_summary_2 - Chapter 2 Program Elements We seek in...

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

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

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

Unformatted text preview: Chapter 2 Program Elements We seek in this section to solve mathematical problems of the type quadrature. I = b a f ( x ) dx ≈ N − 1 i =0 f ( x i ) δ, for the left hand rule. In order to compute this integral approximation, we need to decide the discretization rule for the x i ’s, for instance a uniform spacing, x i = a + δ · a , with δ = b − a N . The answered is stored in a variable ‘sum’ and displayed. The pseudo-code is then given in alrorithm ( 2 ). Algorithm 2 Left point rule 1: Input: f, a, b, N 2: δ ← b − a N 3: sum = 0 4: for i = 0 , . . . , N − 1 do 5: x i = a + δ · i 6: sum = sum + f ( x i ) · δ 7: end for 8: Output: sum 2.1 Data Types • integers int i ; // exact whole number • ﬂoating point values double x ; // Floating point r e a l numbers with 15 d i g i t s • string Strings are not built in so you need to include a string header file. #include < iostream > #include < string > using namespace std ; int main () { string mystring = ”This i s a string ” ; cout << mystring ; return 0; } 6 MAT 5939-04...
View Full Document

{[ snackBarMessage ]}

### Page1 / 4

Cpp_notes_summary_2 - Chapter 2 Program Elements We seek in...

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

View Full Document
Ask a homework question - tutors are online