Programming languages are the languages that are used by humans to talk to computers to make them do what we want. For a computer to understand us we have to use a language the computer understands. Computers are electronic devices that understand the language of electricity; I mean the existence of electrical charge in their complex circuits; this charge is represented by two states on/off or zero/one. This language is called the machine language which is represented by the binary number system so it is also called binary language. So, computers understand the binary language very well, but as humans, it is impractical to write programs in binary language because it is (low level) and we have to memorize every instruction's binary code which is impractical and tedious. Easier languages for human understanding needed to be invented.
Companies and computer scientists started inventing programming languages that are closer to the human understanding level (high level), to make programming easy and more productive, and since the computer revolution thousands of programming languages are written and many of them are obsolete and no longer used today and some of them are still in use and new programming languages are still emerging every couple of years.
C programming language is considered an old programming language, and still widely used today by many companies and programmers in various areas of technology, the language was written in the early seventies by the computer scientist Dennis Ritchie, it was called C because it was derived from the B language and other languages like COBOL and Simula, B language was written by Ken Thompson who is Dennis's friend as they were working at Bell Laboratories, Ken wrote the famous UNIX operating system in C language.
The C language was updated several times from 1977 to 1979, and the standard release was in the mid-eighties. It was called ANSI C, and the language was widely accepted and adopted by many companies and programmers. The C programming language is considered a general-purpose language and a procedural language in that the program consists of some procedures called functions that perform a specific task and the main function that drives the program's execution.
The biggest update that happened to the C language was in 1979, when the computer scientist Bjarne Stroustrup, another friend of Dennis, added the concept of objects and classes and applied the object-oriented programming style with many new features. He called the experimental release C with classes, then the name was changed to C++. C++ has also gone through several updates and releases; every release contains several upgrades, adding new features, removing some, and so on.
The work is in progress on the 2023 release; you can check the official website for the latest language development news at: https://isocpp.org
The main features that Bjarne added to the C language were:
1- Added support for the OOP programming style with all its advanced features like
encapsulation, inheritance, polymorphism, operator overloading, and other features like
virtual functions, exception handling, etc. we will discuss those features in Part 2 of this
book.
2- Added the concept of class templates to work with generic data types.
What are the reasons that make C and C++ programming languages powerful and widely used
today? Here are some reasons:
1- The C language became the base language for many other languages that are derived from
it, like PHP for backend web development, Java, Python, Objective-C, C#, and other
languages; it is also used in building the Oracle database, the UNIX, Linux, and Mac
operating systems, and parts of the Windows operating system.
2- The C programming language is considered by some authors a mid-level language because it
contains features that allow the programmer to use it either on a high level or on a low
level. It provides the techniques needed to let the programmer work directly with memory and
device drivers. It also supports pointers, and this will make programmers write very fast
and efficient programs.
3- It is considered a cross-platform language that works on any platform or operating
system, unlike languages like Visual Basic, which only work under the Windows environment.
You still need to install a compiler for each platform.
4- The C programming language has a small number of keywords, which makes the learning
process easier.
5- It supports a huge number of libraries on various topics.
C++ is not the easiest programming language to learn, but learning it and mastering all its concepts will make it easy to learn any other programming language.
Every science has its terminologies, and programming also has its terms that you need to know and understand:
In this book, we will talk about most of the C/C++ keywords, as new keywords are always added to newer releases:
int | char | float | double | long | short | signed | unsigened |
bool | for | if | while | else | switch | case | default |
do | break | continue | struct | auto | const | enum | static |
goto | extern | return | union | register | typedef | void | volatile |
include |
class | new | delete | private | public | protected | namespace | using |
this | operator | inline | friend | template | try | catch | throw |
virtual | true | false |
The C++ language is a superset of the C language. It supports all the keywords of the C language and more.
Before I start explaining to you the keywords and syntax of the C/C++ languages and writing code, I want to tell you something very important, which is called logical thinking. For you to become a good programmer, you don't have to have full knowledge of the programming language's keywords and syntax; you just have to think logically. There are a lot of computer science students who understand every concept in the language that they study and can memorize every instruction, but they still can't write useful programs to solve simple problems.
The reason behind this is that they learned to program the wrong way. Learning programming is not about memorizing instructions and programs; it's about training your brain to think logically by breaking down any problem into a series of simple logical steps, where every step leads to the next until you reach the solution. This logical thinking ability can be developed by practicing programming, fixing errors, and always trying to solve problems on your own, not by memorizing somebody else's solution. You can look at someone else's solution after you solve problems yourself to benefit from other ideas and learn new ways of thinking. The fun thing about programming is that everybody can solve a particular problem in their own way.
So, any problem you face, try to give it good thinking and write it down as an algorithm with simple, easy steps until you reach the solution or something close to the desired solution, as you can always repeat the process until you are satisfied with the outcome.
It's time for us to learn some code. In this section, I will explain the main parts of every C/C++ program. Don't worry if you don’t understand some of the code lines, as they will become clear in the upcoming chapters.
int main() { }
Program 1.1 is the shortest program possible in C/C++. Run the code below; it has no output but it runs; it is an empty program.
Program 1.1 - https://replit.com/@s4ifbn/cpp-part1-program-1-1
Leave a Comment