Cpp_notes_summary_2

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

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

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 Right Arrow Icon
Ask a homework question - tutors are online