C++ Programming Setup
C++ seekhne ke liye, first step hota hai apne system par sahi environment setup karna. Is blog mein hum IDE install karna, apna pehla C++ program likhna aur run karna, aur C++ program ka structure detail mein samjhenge.
Step 1: IDE Install Karna (Visual Studio Code)
IDE ka matlab hota hai Integrated Development Environment – ek aisa tool jahan aap code likh sakte ho, run kar sakte ho aur debug bhi kar sakte ho.
VS Code Install Karne ke Steps:
- VS Code download karo – https://code.visualstudio.com
- Setup file install karo (Next, Next karke complete install ho jayega).
- Ek aur zaroori cheez hai – C++ compiler. Hum use karenge MinGW.
MinGW Compiler Setup:
- Download karo MinGW: https://sourceforge.net/projects/mingw/
- Installation ke baad bin folder ka path copy karo (example:
C:MinGWin
). - Ye path ko Environment Variables > System Variables > Path me add karo.
- Command Prompt khol ke likho:
g++ --version
Agar version show ho gaya to setup successful hai!
Step 2: Apna Pehla C++ Program Likho aur Run Karo
Code:
#include <iostream>
using namespace std;
int main() {
cout << "Hello, C++ World!" << endl;
return 0;
}
Isse run kaise karein?
- File ko save karo as
hello.cpp
. - Terminal open karo (VS Code ke andar ya CMD).
- Compile command likho:
g++ hello.cpp -o hello
. - Phir run karo:
./hello
.
Agar output aaya Hello, C++ World!, to done Environment poori tarah setup ho gya aur program bhi run ho gya.
Step 3: C++ Program Ka Structure Samjho
Har C++ program ka ek basic structure hota hai. Lets breakdown:
#include <iostream> // Header file, input-output ke liye
using namespace std; // Namespace use kar rahe hain
int main() { // Main function – entry point
cout << "Hello"; // Output command
return 0; // Program successful terminate hota hai
}
Points to Remember:
#include <iostream>
: Ye library hoti hai input/output ke liye.using namespace std;
: Humstd::cout
likhne se bachne ke liye use karte hain.int main()
: Har C++ program yahin se start hota hai.return 0;
: Ye batata hai ki program sahi se run hua.
Conclusion:
- VS Code aur MinGW setup karna hai,
- Apna pehla C++ program likh ke run karna hai,
- Aur C++ ka basic structure samajhna hai.
Comments