Notes – First C++ Program using Turbo C++ and VS Code

Let’s understand how to write, save, compile, and run your first C++ program using both Turbo C++ (traditional IDE) and Visual Studio Code (modern IDE).

1. Writing First Program in Turbo C++

Turbo C++ is a DOS-based IDE that many schools and colleges still use.

Steps to Run:

  1. Open Turbo C++.
  2. Go to File > New to create a new file.
  3. Type your C++ program.
  4. Save the file with .cpp extension.
  5. Press Ctrl + F9 to compile and run the program.
  6. Press Alt + F5 to view the output.

Sample Code:

#include <iostream.h>
#include <conio.h>

void main() {
clrscr(); // clear screen
cout << "Welcome to C++ Programming!";
getch(); // wait for key press
}

Turbo C++ uses old-style headers like <iostream.h> and functions like clrscr() and getch() which are not part of modern C++.


2. Writing First Program in VS Code

Visual Studio Code is a modern editor. You need to set up a C++ compiler (like MinGW) before using it.

Setup Required:

  • Install VS Code
  • Install C++ Extension by Microsoft
  • Install MinGW or g++ compiler
  • Add the compiler path to your system environment variables

Steps to Run:

  1. Create a folder and open it in VS Code.
  2. Create a new file with .cpp extension.
  3. Write the program.
  4. Open Terminal in VS Code.
  5. Compile the code using: bashCopyEditg++ filename.cpp -o output
  6. Run the output using: bashCopyEdit./output

Sample Code (Modern C++):

#include <iostream>
using namespace std;

int main() {
cout << "Welcome to C++ Programming!" << endl;
return 0;
}

Turbo C++ vs VS Code (Quick Comparison)


FeatureTurbo C++VS Code (with g++)
Header FilesUses old styleUses modern C++ headers
Editor StyleDOS-basedModern GUI
CompatibilityOutdatedUp-to-date
Usage in IndustryVery RareWidely used
Recommended forBeginners (legacy)Beginners to advanced