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
-
Open an Editor:
- Use VS Code, or any other editor of your choice.
-
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;
}
-
-
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
- Open Command Prompt:
- Open the Command Prompt (you can search for “cmd” in the Start menu).
- 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
- Compile the Program:
- Use the GCC compiler to compile your program. Run the following command: