Compile and run your first program

To compile and run your first program using the GCC compiler, follow the below steps:

Writing Your First C++ Program

  1. Open an Editor:

    • Use VS Code, or any other editor of your choice.
  2. Write a simple C program:

    • Write the following simple "" program:

      #include <bits/stdc++.h>

      using namespace std;

      int main()

      {

      cout<<“Hello everyone, Welcome to gurucodes fam!"<<endl;

      return 0;

      }

  3. Save the File:

    • Save the file with a “.cpp” extension. For example, “hello.cpp”.
    • Save the file in a directory where you can easily navigate using the Command Prompt.

Compiling the Program

  1. Open Command Prompt:
  • Open the Command Prompt (you can search for “cmd” in the Start menu).
  1. Navigate to the directory:
  • Use the “cd” command to navigate to the directory where you saved your “hello.cpp” file.

    For example: cd C:\gurucodes
    
  1. Compile the Program:
  • Use the GCC compiler to compile your program. Run the following command:

Questions? : Reach Out