Cpp_notes_summary_1

Cpp_notes_summary_1 - Chapter 1 The Program Our first...

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 1 The Program Our first example consists of the following algorithm: Algorithm 1 First example 1: i ← 2 2: j ← 2 3: k ← i + j 4: PRINT k FIRST EXAMPLE.cpp #include < iostream > using namespace std ; int main () { int i , j , k ; i =2; j =2; k=i+j ; cout << k ; return 0; } Save as FIRST EXAMPLE.cpp FIRST EXAMPLE Commands and Output g++ FIRST EXAMPLE. cpp ./ a . out FIRST EXAMPLE Commands and Output g++ FIRST EXAMPLE. cpp − o FIRST EXAMPLE CPP ./FIRST EXAMPLE CPP 4 MAT 5939-04 Pierre Garreau 1.1 Description of the program • Note: C++ is case sensitive. • #include < iostream > is a preprocessor directive to include the iostream header file in the program before compilation. We need this header file to be able to output the results to the screen. • using namespace std ; is a shorthand for the usage of functions belonging to the namespace std. • int main () is a function that returns an integer. Every C++ program starts by executing the main() function....
View Full Document

This note was uploaded on 01/15/2012 for the course MAT 5939 taught by Professor Garreau during the Fall '11 term at FSU.

Page1 / 2

Cpp_notes_summary_1 - Chapter 1 The Program Our first...

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