C++ Programming Fundamentals Lecture 3 PDF
Document Details
Uploaded by RefinedFeynman
Faculty of Computer Science and Information Technology
2017
Dr. Mustafa
Tags
Related
Summary
This document is lecture 3 notes on C++ programming, including Software Development Life Cycle (SDLC) concepts and introduction to C++. The lecture was given by Dr. Mustafa in 2017. It is beneficial for those learning about computer programming.
Full Transcript
Programming Fundamentals SDLC, Intro to C++ Dr. Mustafa © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. It is the application of standard business practices to building software applications. It’s typically divided into six to eight steps: Planning, Requi...
Programming Fundamentals SDLC, Intro to C++ Dr. Mustafa © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. It is the application of standard business practices to building software applications. It’s typically divided into six to eight steps: Planning, Requirements, Design, Coding, Document, Test, Deploy, Maintain. Some project managers will combine, split, or omit steps, depending on the project’s scope. More details: https://en.wikipedia.org/wiki/Systems_development_life_c ycle © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. Chapter 2 of C++ How to Program, 10/e © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. We now introduce C++ programming, which facilitates a disciplined approach to program development. Most of the C++ programs you’ll study in this book process data and display results. © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. Simple program that prints a line of text (Fig. 2.1). © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. // indicates that the remainder of each line is a comment. ◦ You insert comments to document your programs and to help other people read and understand them. ◦ Comments are ignored by the C++ compiler and do not cause any machine-language object code to be generated. A comment beginning with // is called a single-line comment because it terminates at the end of the current line. You also may use comments containing one or more lines enclosed in. © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. A preprocessing directive is a message to the C++ preprocessor. Lines that begin with # are processed by the preprocessor before the program is compiled. #include notifies the preprocessor to include in the program the contents of the input/output stream header file. ◦ This header is a file containing information used by the compiler when compiling any program that outputs data to the screen or inputs data from the keyboard using C++- style stream input/output. © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. You use blank lines, space characters and tab characters (i.e., “tabs”) to make programs easier to read. ◦ Together, these characters are known as white space. ◦ White-space characters are normally ignored by the compiler. © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. main is a part of every C++ program. The parentheses after main indicate that main is a program building block called a function. C++ programs typically consist of one or more functions and classes. Exactly one function in every program must be named main. C++ programs begin executing at function main, even if main is not the first function defined in the program. The keyword int to the left of main indicates that main “returns” an integer (whole number) value. ◦ A keyword is a word in code that is reserved by C++ for a specific use. ◦ For now, simply include the keyword int to the left of main in each of your programs. © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. A left brace, {, must begin the body of every function. A corresponding right brace, }, must end each function’s body. A statement instructs the computer to perform an action. Together, the quotation marks and the characters between them are called a string, a character string or a string literal. We refer to characters between double quotation marks simply as strings. ◦ White-space characters in strings are not ignored by the compiler. Most C++ statements end with a semicolon (;), also known as the statement terminator. ◦ Preprocessing directives (like #include) do not end with a semicolon. © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. Typically, output and input in C++ are accomplished with streams of data. When a cout statement executes, it sends a stream of characters to the standard output stream object— std::cout—which is normally “connected” to the screen. The std:: before cout is required when we use names that we’ve brought into the program by the preprocessing directive #include. ◦ The notation std::cout specifies that we are using a name, in this case cout, that belongs to “namespace” std. ◦ The names cin (the standard input stream) and cerr (the standard error stream) also belong to namespace std. © Copyright 2017 by Pearson Education, Ltd. All Rights Reserved. In the context of an output statement, the