Introduction to C++ Programming.

Introduction to C++ Programming.

The C++ program was developed by Bjarne Stroustrup in 1979 at Bell Lab which is basically an extended version of the C program. After the release of C++ in 1998 by ISO five major updates have been made in the language (C++ 03, C++11, C++14, C++17, C++20), and each time more new functionality has been added.


The initial version of C++ was called "C with Classes" having extra features like data abstraction, object-oriented programming, and generic programming. 


Usage of C++ Programming Language.

  • It is used for making Video Games.
  • It is used for making High-Performance Financial Applications.
  • It is used for making Embedded Software.
  • It is used in Artificial Intelligence and Neural Networks.
  • It is used for Developing a Web Browser.
  • It is used for building Operating Systems.


C++ is a high-level programming language and a single statement of C++ may compile into many machine language instructions. Let's understand the basic syntax of C++ programming in detail by using below simple example. 

#include<iostream>

int main()
{
    std::cout<<"Hello AlgoLesson";
    return 0;
}
Output:
Hello AlgoLesson

Let's understand each line of the above code one by one:

Line 1: It is a Preprocessor directive telling that you have included iostream header file which is part of the C++ standard library. The iostream library allows us to read and write from or to the console.

Line 2: It is a blank space that will be ignored by the compiler. It is not necessary to give this blank space but it helps read the code more efficiently. 

Line 3:  In this line, you are defining the main function and every C++ program must have this special main function. Whenever you run the program, all the statements inside the main function will execute in sequence order and the program gets terminated when the last statement of the main function has been executed.

Line 4 and Line 7: These two lines indicate the opening and closing brackets that define the function body and tell the compiler which are lines that belong to the main function.

Line 5: This statement helps you to print your output on the console (cout stands for character output) and the << operator is used to send the output character to the console. In our case, we are sending "Hello AlgoLesson" to the console.

Line 6: It is a return statement which is the last statement of the program that sends a value back to the operating system in order to indicate whether the program has been successfully executed or not. 

What is Syntax Error in Programming?

The syntax is basically specific rules that you need to follow for writing code and different programming languages have their own syntax. You need to write each statement by following these rules in order to write a good program. 

For example, all statements in C++ programming must end with a semicolon. If you make any mistake in the syntax of the program then while running the code your compiler will send you a syntax error with a short message describing the possible cause of the error. 

Syntax Error in C++ Programming
C++ Syntax Error when you miss a semicolon

⚡ Please share your valuable feedback and suggestion in the comment section below or you can send us an email on our offical email id ✉ algolesson@gmail.com. You can also support our work by buying a cup of coffee ☕ for us.

Similar Posts

No comments:

Post a Comment


CLOSE ADS
CLOSE ADS