TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

C++

Compile & Execute C++ Program

Overview

In this tutorial, we will learn to compile and execute a C++ program using the Windows command line prompt.

Install GNU GCC C++ Compiler

Steps to install GNU GCC C++ compiler:

https://www.testingdocs.com/install-gnu-c-c-compiler-on-windows/

Write C++ code

General steps to execute the program are as follows:

  • Launch Text editor like Notepad, Notepad++, etc.
  • Write C++ source code.
  • Save the file with the .cpp file extension. For Example, we will save the file as main.cpp

 

C++ Code in Notepad Text Editor

 

/************************************
* Hello World C++ Program
* Filename: main.cpp
* C++ Tutorials - www.TestingDocs.com
*************************************/

// C++ Header file
#include 
using namespace std;
// Entry Point : main routine.
int main()
{
 cout << "Hello, World!"; // print message
 return 0;
}

Compile C++ Program

Open the Command prompt and issue the following command to compile the code.

\> g++ main.cpp

If there are no errors in the code a.exe executable file would generate.

Execute C++ Program

Now, type ‘a.exe’ to run the C++ program. You would be able to see ‘ Hello, World !’ printed on the console.

Compile C++ Program Command Prompt

That’s it. We have successfully compiled and executed a C++ program using the Windows command prompt.

—

C++ Tutorials

C++ Tutorials on this website:

https://www.testingdocs.com/c-coding-tutorials/

For more information on the current ISO C++ standard

https://isocpp.org/std/the-standard

Related Posts

g not found OpenSuse

C++ /

Install GCC C++ Compiler on OpenSuse

sum of digits c program

C++ /

Sum of Digits of a Number C++ Program

C++ Hello World Program

C++ /

C++ Hello World Program

C++ /

C++ Program to Find Quadratic Equation Roots

C Class Constructor

C++ /

Define C++ Class Constructor

‹ C++ Program Structure› Basic C++ Syntax

Recent Posts

  • Update draw.io on Windows
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com