...

Programming languages - C++

Back to Course

Lesson Description


Lession - #33 C++ Basic Syntax


C++ Program Structure

#include 
using namespace std;

// main(>
is where program execution begins. int main(>
{ cout << "Hello World"; // prints Hello World return 0; }

Allow us to take a gander at the different pieces of the above program −
 

  • The C++ language characterizes a few headers, which contain data that is either important or helpful to your program. For this program, the header is required.
  • The line utilizing namespace std; advises the compiler to utilize the std namespace. Namespaces are a moderately late expansion to C++.
  • The following line '//main(>
    is where program execution starts.' is a single-line remark accessible in C++. Single-line remarks start with//and stop toward as far as it goes.
  • The line int main(>
    is the primary function where program execution starts.
  • The following line cout << "Hi World"; causes the message "Hi World" to be shown on the screen.
  • The following line return 0; ends main( >
    function and makes it return the worth 0 to the calling process.

Compile and Execute C++ Program

How about we take a gander at how to save the file, compile and run the program. Kindly follow the means given beneath −

  • Open a text editor and add the code as above.
  • Save the record as: hello.cpp
  • Open a command prompt and go to the directory where you saved the file.
  • Type 'g++ hello.cpp' and press enter to compile your code. Assuming that there are no blunders in your code the command prompt will take you to the following line and would create a.out executable file.
  • Presently, type 'a.out' to run your program.
  • You will actually want to see ' Hello World ' imprinted on the window.

 

 

 

 

 


tutorialspoint c++, C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs
The main difference between C and C++ is that C is a procedural programming language that does not support classes and objects.
Learn how to use C++ to develop applications, services, and tools for your platforms and devices. ... c++ microsoft, C, and Assembler documentation.
The atan2 C++ function returns the inverse tangent of a coordinate in radians. It is defined in the cmath header file.