C++ Programming
Complete Guide to Learn the Basics of C++ Programming in 7 Days
By
Xavier S Martin
Copyright 2020 by Xavier S Martin- All rights reserved.
The content contained within this book may not be reproduced, duplicated or transmitted without direct written permission from the author or the publisher.
Under no circumstances will any blame or legal responsibility be held against the publisher, or author, for any damages, reparation, or monetary loss due to the information contained within this book, either directly or indirectly.
Legal Notice:
This book is copyright protected. It is only for personal use. You cannot amend, distribute, sell, use, quote or paraphrase any part, or the content within this book, without the consent of the author or publisher.
Disclaimer Notice:
Please note the information contained within this document is for educational and entertainment purposes only. All effort has been executed to present accurate, up to date, reliable, complete information. No warranties of any kind are declared or implied. Readers acknowledge that the author is not engaged in the rendering of legal, financial, medical or professional advice. The content within this book has been derived from various sources. Please consult a licensed professional before attempting any techniques outlined in this book.
By reading this document, the reader agrees that under no circumstances is the author responsible for any losses, direct or indirect, that are incurred as a result of the use of the information contained within this document, including, but not limited to, errors, omissions, or inaccuracies.
Table of Contents
Introduction
C++ is a computer programming language widely used for general-purpose programming. It is an extension of C-language. The basic understanding of C++ can be acquired from C. Thats why both computer languages are represented as C/C++. Bjarne Stroustrup developed this multi-paradigm language in 1979.
In todays world, many operating systems use C++ as their basic language. Some system drivers, browsers, and games are based on C++ programs. It is a free-form, compiled, and statically-typed programming language. Many professionals believe that C++ is the most efficient language to achieve the desired results.
In the Complete guide to learn the basics of C++ programming in 7 days, I have covered all the essential basic concepts for beginners. It is a step by step guide, which makes sure the understanding of C++ programming. First of all, there is a need to know the structure and syntax of C++, along with the basic expressions. Then, it guides the major Functions such as mathematical manipulation and Standard Library. Moreover, there are complete guidance about the selection making of operators and logical data, concepts of Arrays, Pointers, Classes and Strings in C++.
While there are so many great programming languages, but C++ is the most favorite owing to have the privilege of the first Object-Oriented Programming language. Nowadays, there are several high-level languages with simple syntax and user-friendly options. Still, programmers cant deny the importance of C++ because of its huge number of open-source libraries, wide applications, and highly fast run-time performance.
This guide is designed for beginners who want to learn C++ in 7 days. You will discover this language by making your programs while reading this book.
Chapter 1: Introduction to C++
In the following chapter, we will discuss about the evolution of computer programming languages and their evolution from machine languages.
As we know C++ is a high-level language. Well discuss the concepts of C++, in this chapter. Moreover, you will be able to write your first program, after going through this chapter, i.e. Hello World. Furthermore, youll understand the concepts of Constants, Variables, Data types and some of the operators that may help you writing and understanding a C++ program.
1.1 Background of C++
C++ is considered a properly structured programming language, thats why this is so popular. C++, as you know, is a high level language because it allows a programmer to concentrate on the problem at his hand, without worrying about the system that the program may be using. There are many languages who claim to be system or machine independent but C++ is one of the best among them.
Like many other languages, C++ is basically derived from ALGOL, which was the first language to have a structure. ALGOL was developed in the early 1960s and it made a path for structured programming and its concepts. Very first work in ALGOL was done by two scientists name as Guiseppe Jacopini and Corrado Bohm. Both of them published a research in 1960 which defined a thorough idea of structured programming.
In 1967, a computer scientist named as Martin Richards designed a language designed a programming language; he named Basic Combined Programming Language aka. BCPL. In 1970, Ken Thompson developed a language, known as B. Following him, Dennis Ritchie, in 1972, developed the concept of language C.
Following all the concepts from the languages, ALGOL, BCPL, B and C, Bjarne Stroustrup, developed C++ in mid 1980s.
1.2 C++ Programming
Now, when you know about the background of C++, i guess, youll be eager to write your first program. This section will let you know the basic parts of a C++ program, so that youll be able to write your very first program.
How to write a C++ program
First of all, we need to understand, the Global Declaration. Your program is considered a little world; a world of computer universe. So, we may start our program with global declaration.
Secondly, only one function, in your program must be named as main. Main is the starting of the basic program, after global declaration. Main can have two kinds of code;
Declaration
Declaration is considered the data that you may use to justify or write your program or function. If you declare something in a function, itll be known as Local Declaration. We call them local declarations because they are read, only be the function itself.
Statements
Statements are some commands to the machine that is using the program. Statements cause the machine to perform the actions, such as adding or subtracting numbers, multiply them, taking their average etc.
Simple Program
We know that C++ allow us to make declarations and statements at the same time, but, every time, we should write a program, which should be well organized so that any other programmer or even the machine could understand it fast. This is the reason, we follow the language Cs concepts of organization. The concept states that one should perform declaration first and statements second. Moreover, most of the times, one should use comments for the identification of the sections; Declarations and Statements.
A C++ program is a mixture of two components main (Main) and fun (function). In other words, function is called or used by main. Usually, we write the code for the main, first. After that, well code the function and sub functions, in their order.
Moving forward, there is another concept; concept of preprocessor directives or precompiler directives. These are some statements which give instructions to a compiler or processor to execute the program in a unique pattern.
A statement which is globally used as a preprocessor directive is, include. This statement allows the compiler to extract some data from global libraries, known as header files. Without these header files or libraries, you will not be able to write even a single program, because itll be so complex to write the commands even for your input or output. Even, you will need an include command, to write your very first program. This will be used to instruct C++ that you will be in need for the input and output libraries, so that you may print your desired data to the console screen.