Introduction

Let's see one simple example of C++ program and learn some basic syntax of it.

Syntax:

#include <iostream> int main() { std::cout << "Hello World!"; return 0; }

Line 1:   #include <iostream>   is a statement to include the header file library. <iostream> is a library that lets us work with input and output functions, such as cout.

Line 2: blank space. C++ ignores white space, but we need white spaces to increase our code readability.

Line 3: the main() function. As its name implies, main() function consists of the main code to be executed. Any code inside the curly brackets { } is called “inside the main() function”

Line 4: std::cout is a function used to output or print text to the screen.

Line 5: return 0; ends the main() function.

Note: every C++ statement ends with a semicolon (;)


  
      

Also Look at Various Topic Below!


      
Variable and Data Type

Learn more about variable and data type here.

Input and Output

Learn more about input and output here.


                      
                        
                      
                    
Operators

Learn more about operators here.


                    
                      
                    
                  

    
        
Arrays

Learn more about arrays here.


                        
                          
                        
                      
Conditional and Loops

Learn more about conditional and loops here.

Pointers

Learn more about pointers here.


                      
                        
                      
                    

    
          
Functions

Learn more about functions here.

Classes

Learn more about classes here.

Modules

Learn more about modules here.


    
            
File Handling

Learn more about file handling here.

Cheat Sheet

Learn more about C++ cheat sheet here.