Full Transcript

1 2 Introduction to C+ + Programming  2006 Pearson Education, Inc. All rights reserved. 2 OBJECTIVES  In this chapter you will learn:  To...

1 2 Introduction to C+ + Programming  2006 Pearson Education, Inc. All rights reserved. 2 OBJECTIVES  In this chapter you will learn:  To write simple computer programs in C++.  To write simple input and output statements.  To use fundamental types.  Basic computer memory concepts.  To use arithmetic operators.  The precedence of arithmetic operators.  To write simple decision-making statements.  2006 Pearson Education, Inc. All rights reserved. 3 2.1 Introduction 2.2 First Program in C++: Printing a Line of Text 2.3 Modifying Our First C++ Program 2.4 Another C++ Program: Adding Integers 2.5 Memory Concepts 2.6 Arithmetic 2.7 Assignment Operators 2.8 Increment and Decrement Operators 2.9 Decision Making: Equality and Relational Operators 2.10 Wrap-Up  2006 Pearson Education, Inc. All rights reserved. 4 2.1 Introduction C++ programming – Facilitates disciplined approach to computer program design – Programs process information and display results Five examples demonstrate – How to display messages – How to obtain information from the user – How to perform arithmetic calculations – How to make decisions  2006 Pearson Education, Inc. All rights reserved. 5 2.2 First Program in C++: Printing a Line of Text Simple program – Prints a line of text – Illustrates several important features of C++  2006 Pearson Education, Inc. All rights reserved. 6 2.2 First Program in C++: Printing a Line of Text (Cont.) Comments – Explain programs to other programmers Improve program readability – Ignored by compiler – Single-line comment Begin with // Example – // This is a text-printing program. – Multi-line comment Start with  2006 Pearson Education, Inc. All rights reserved. 1 // Fig. 2.1: fig02_01.cpp 7 Single-line comments 2 // Text-printing program. Outline 3 Function #include // main returns allows program an data to the screen to output Preprocessor directive to 4 Left brace { integer valuebegins functioninput/output stream include 5 // function main bodyprogram begins execution Function main Statements end with a headerappears file fig02_01.cpp exactly once in every C++ semicolon ; 6 int main() 7 { (1 of 1) program 8 std::cout

Use Quizgecko on...
Browser
Browser