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:
- Open Turbo C++.
- Go to
File > Newto create a new file. - Type your C++ program.
- Save the file with
.cppextension. - Press
Ctrl + F9to compile and run the program. - Press
Alt + F5to 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 likeclrscr()andgetch()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:
- Create a folder and open it in VS Code.
- Create a new file with
.cppextension. - Write the program.
- Open Terminal in VS Code.
- Compile the code using: bashCopyEdit
g++ filename.cpp -o output - 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)
| Feature | Turbo C++ | VS Code (with g++) |
|---|---|---|
| Header Files | Uses old style | Uses modern C++ headers |
| Editor Style | DOS-based | Modern GUI |
| Compatibility | Outdated | Up-to-date |
| Usage in Industry | Very Rare | Widely used |
| Recommended for | Beginners (legacy) | Beginners to advanced |
