Professional Documents
Culture Documents
PF Lec04 Starting With Basics of C++ 1-02-2023
PF Lec04 Starting With Basics of C++ 1-02-2023
Lecture 4
Copyright © 2013 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1
Introduction to C++
• A well-designed program
Copyright © 2013 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2
Functions
Copyright © 2013 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 5
Examples of identifiers
• 1AB3
(Begins with a number, which violates rule 1.)
• E*6
(Contains a special character, which violates rule 2.)
• for
(Consists of a keyword, which violates rule 3.)
6
Examples of identifiers
Copyright © 2013 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 7
Function names
• Note :
• Function names end with a parenthesis.
8
The main() Function
9
The main() Function
Copyright © 2013 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 10
The cout Object
11
Preprocessor commands
• The first line of the program is a preprocessor command that uses the
reserved word include:
• #include <iostream>
• Begin with a pound sign (#) and perform some action before the
compiler translates the source program into machine code.
13
Example
Output ?
15