chapter 2

34
Chapter 2 Elements of a C++ program 1

Upload: linus-jenkins

Post on 31-Dec-2015

22 views

Category:

Documents


0 download

DESCRIPTION

Chapter 2. Elements of a C ++ program. Review. Algorithms describe how to solve a problem Structured English (pseudo-code) Programs form that can be translated into machine instructions high-level programming language: C++. The First C++ Program. “Hello, world!”. - PowerPoint PPT Presentation

TRANSCRIPT

Chapter 2

FunctionA C++ program is a collection of one or more functions (subprograms).Each function does some specific task in order to solve the problem.

There must be a function called main()Execution always begins with the first statement in function main()Any other functions in your program are subprograms and are not executed until they are called

Try helloWorldAmerica.cpp5The output statement: coutbegins with coutendl means end of the line. (same as \n)It moves the cursor to the next line of the displayIt does not have to be the last thing in a cout statementeach thing (literal, variable, endl) is preceded with