Introduction C++ Programming / PDF
Introduction C++ Programming / PDF
Origins of the C++ Language
The first thing that people notice about the C++ language is its unusual name.
Is there a C programming language, you might ask? Is there a C– or a C–– language? Are there programming languages named A and B? The answer to most of these questions is no. But the general thrust of the questions is on the mark. There is a B programming language; it was not derived from a language
called A, but from a language called BCPL. The C language was derived fro
the B language, and C++ was derived from the C language. Why are there two pluses in the name C++? As you will see in the next chapter, ++ is an operation in the C and C++ languages, so using ++ produces a nice pun. The languages BCPL and B do not concern us. They are earlier versions of the C programming
language. We will start our description of the C++ programming language with
a description of the C language.
The C programming language was developed by Dennis Ritchie of AT&T Bell Laboratories in the 1970s. It was first used for writing and maintaining the UNIX operating system. (Up until that time UNIX systems programs were written either in assembly language or in B, a language developed by Ken
Thompson, who is the originator of UNIX.) C is a general-purpose language that can be used for writing any sort of program, but its success and popularity are closely tied to the UNIX operating system. If you wanted to maintain your UNIX system, you needed to use C. C and UNIX fit together so well that soon
not just systems programs, but almost all commercial programs that ran under UNIX were written in the C language.
C became so popular that versions of the language were written for other popular operating systems; its use is not limited to computers that use UNIX. However, despite its popularity, C is not
without its shortcomings.
The C language is peculiar because it is a high-level language with many of the features of a low-level language. C is somewhere in between the two extremes of a very high-level language and a low-level language, and therein lies both its strengths and its weaknesses. Like (low-level) assembly language, C language programs can directly manipulate the computer’s memory.
On the other hand, C has many features of a high-level language, which makes it easier to read and write than assembly language. This makes C an excellent
A Sample C++ Program
Display 1.8 contains a simple C++ program and the screen display that might be generated when a user runs and interacts with this program. The person who runs a program is called the user. The text typed in by the user is shown in boldface to distinguish it from the text written by the program.
On the actual screen both texts would look alike. The person who writes the program
is called the programmer. Do not confuse the roles of the user and the programmer. The user and the programmer might or might not be the same person.
For example, if you write and then run a program, you are both theprogrammer and the user. With professionally produced programs, the programmer (or programmers) and the user are usually different persons.
In the next chapter we will explain in detail all the C++ features you need to write programs like the one in Display 1.8, but to give you a feel for how a C++ program works, we will now give a brief description of how this particular program works. If some of the details are a bit unclear, do not worry. In this section, we just want to give you a feel for what a C++ program is.
The beginning and end of our sample program contain some details that need not concern us yet. The program begins with the following lines:
#include
using namespace std;
int main( )
{
For now we will consider these lines to be a rather complicated way of saying
“The program starts here.”
The program ends with the following two lines:
return 0;.........
Table of Contents:
INTRODUCTION TO C++
Origins of the C++ Language
A Sample C++ Program
Pitfall:
Using the Wrong Slash in
Programming Tip:
Input and Output Syntax
Layout of a Simple C++ Program
Pitfall:
Putting a Space before the
include
File Name
Compiling and Running a C++ Program
Programming Tip:
Getting Your Program to Run
-----------------------
Sample of the pdf document
The first thing that people notice about the C++ language is its unusual name.
Is there a C programming language, you might ask? Is there a C– or a C–– language? Are there programming languages named A and B? The answer to most of these questions is no. But the general thrust of the questions is on the mark. There is a B programming language; it was not derived from a language
called A, but from a language called BCPL. The C language was derived fro
the B language, and C++ was derived from the C language. Why are there two pluses in the name C++? As you will see in the next chapter, ++ is an operation in the C and C++ languages, so using ++ produces a nice pun. The languages BCPL and B do not concern us. They are earlier versions of the C programming
language. We will start our description of the C++ programming language with
a description of the C language.
The C programming language was developed by Dennis Ritchie of AT&T Bell Laboratories in the 1970s. It was first used for writing and maintaining the UNIX operating system. (Up until that time UNIX systems programs were written either in assembly language or in B, a language developed by Ken
Thompson, who is the originator of UNIX.) C is a general-purpose language that can be used for writing any sort of program, but its success and popularity are closely tied to the UNIX operating system. If you wanted to maintain your UNIX system, you needed to use C. C and UNIX fit together so well that soon
not just systems programs, but almost all commercial programs that ran under UNIX were written in the C language.
C became so popular that versions of the language were written for other popular operating systems; its use is not limited to computers that use UNIX. However, despite its popularity, C is not
without its shortcomings.
The C language is peculiar because it is a high-level language with many of the features of a low-level language. C is somewhere in between the two extremes of a very high-level language and a low-level language, and therein lies both its strengths and its weaknesses. Like (low-level) assembly language, C language programs can directly manipulate the computer’s memory.
On the other hand, C has many features of a high-level language, which makes it easier to read and write than assembly language. This makes C an excellent
A Sample C++ Program
Display 1.8 contains a simple C++ program and the screen display that might be generated when a user runs and interacts with this program. The person who runs a program is called the user. The text typed in by the user is shown in boldface to distinguish it from the text written by the program.
On the actual screen both texts would look alike. The person who writes the program
is called the programmer. Do not confuse the roles of the user and the programmer. The user and the programmer might or might not be the same person.
For example, if you write and then run a program, you are both theprogrammer and the user. With professionally produced programs, the programmer (or programmers) and the user are usually different persons.
In the next chapter we will explain in detail all the C++ features you need to write programs like the one in Display 1.8, but to give you a feel for how a C++ program works, we will now give a brief description of how this particular program works. If some of the details are a bit unclear, do not worry. In this section, we just want to give you a feel for what a C++ program is.
The beginning and end of our sample program contain some details that need not concern us yet. The program begins with the following lines:
#include
using namespace std;
int main( )
{
For now we will consider these lines to be a rather complicated way of saying
“The program starts here.”
The program ends with the following two lines:
return 0;.........
Click here for Download PDF / FREE
Introduction C++ Programming / PDF
0 commentaires: