C++ Programming Language

C++ is a multi-paradigm language,it can be used to create games, desktop apps, operating systems, and other applications.It supports at least seven different programming styles. It enables you to comprehend a computer's internal architecture , as well as how it stores and retrieves data. C++ is an extended version of C, so the C part is very low level.

C++ was invented by Bjarne Stroustrup in 1979. It was designed as an extension of the C programming language, so its original name is "CwithClasses". The goal of Stroustrup was to add flexibility and OOP (Object Oriented Programming) to the C language. He added features such as classes, strong type checking, default function arguments, and basic inheritance. The name was changed to C++ in 1983 and the name C++ comes from the ++ operator .

What are the features of C++?

Typed Statically

Because C++ is a statically typed programming language , the compiler cannot make assumptions about the type of data. as these are determined at compile-time, it aids the compiler in detecting errors and bugs before the program is executed.

Programming language with multiple paradigms

As mentioned earlier that C++ supports at least seven different programming styles it allows developers to pick and choose which one they prefer. C ++ has been used to develop almost all major operating systems such as Windows, Mac OSX, and Linux . Apart from the operating system, the core of many browsers, such as Mozilla Firefox and Chrome, was written using C ++. It was also used to develop the most popular database system called MySQL. C ++ is widely used to develop new programming languages such as C #, Java, JavaScript, Perl, UNIX C shell, PHP, Python, and Verilog.

Game Development

C++ is so fast that programmers can perform procedural programming of CPU-intensive functions and have better control over their hardware. Therefore, it is widely used in the development of game engines.

Embedded Systems

C++ is heavily used in the development of software for MRI machines, medical and technical applications such as high-end CAD / CAM systems.

If you have done programming before then you might be aware of some of the terms like:-

Now Let's take a look at some C ++ code! Before looking at the code let's first understand "What is Syntax?"

What is Syntax?

Welcome to the C++ syntax. The syntax is similar to the grammar of programming languages. This is the basic foundation for everything you write in C++. These are the rules that define how to write and understand C ++ code. To get used to the syntax, take a look at the code sample.

#include < iostream > // header file library
using namespace std; //using standard library
int main() { //main function
cout < < "Hello World \n"
return 0 ; //no other output or return
} //end of code to execute

Explanation of syntax

#include   is a library of header files. A header file is used to import features into your program. We're essentially asking the program to copy the contents of a file called. This is an abbreviation for input and output stream, and it defines the parameters for the objects in our code.

When we use the using namespace std; , we are referring to object and variable names from the standard library (std). The keyword std and the operator:: are frequently used to abbreviate this statement. The main function is specified using the int main (). It is a critical component of C++ programs. A function is essentially the definition of an action for your code. Anything contained within the curly brackets will be executed.

cout is a thing (pronounced see - out). It defines our outputs in this example: the strings of words. On the second line, we use cout to create a new object. The character \n causes the text to execute on a new line.

What are Keywords?

Keywords are predefined names that can be used to identify objects in your code.

What are Variables?

Variables also known as Identifiers are similar to containers that hold values. To declare a variable, use the appropriate keyword to assign it a value and a type. All variables in C++ require a name.

What are Objects?

An object is a collection of data on which we can act. In C++, an object has an attribute (its traits) and a method (its abilities). A class is used to create objects. Consider this to be a blueprint for an object. The class keyword is used to create a class. You must specify the type of access, such as public, private, or protected. The public keyword indicates that the class is accessible from outside of it. After you've defined your class, you can move on to defining your attributes and objects.

What are Functions?

Functions are blocks of code that execute when called. They are your program's workhorse and are used to perform operations and manipulations on your code. They are critical for code reusability and aid in the modularization of your code. Consider these to be actions that you initiate. There are predefined functions in C++, such as the main() function.

To create a function, you must give it a name and surround it with parentheses ( ). You can then use that name to call this function at any time. You can also assign return values to your functions, which determine whether or not the function should output any data. The void keyword indicates that no return will be made. The return keyword, on the other hand, indicates that a data type output is desired.

What are Conditional Statements?

These allow you to determine whether or not a block of code should be executed.

C++ has the following conditional statements:

If :- a specified condition is true, use if to specify a block of code to be executed.

Else :- If the same condition is false, use else to specify a block of code to be executed.

Else if :- If the first condition is false, use else if to specify a new condition to test.

Switch :- Switch is used to specify a large number of alternative code blocks to be executed.

What are Loops?

Conditional Statements are similar to loops. They run code block as long as a certain condition is met.

In C++, there are two kinds of loops:

While loops: This loop will iterate through your code as long as a condition returns true.

for loops: this is used when you know exactly how many times you want your code to loop.