elements of a c++ program 1. review algorithms describe how to solve a problem structured english...

34
Chapter 2 Elements of a C++ program 1

Upload: austen-morton

Post on 11-Jan-2016

215 views

Category:

Documents


1 download

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