AnyCompiler

Aapka Pehla C++ Program

Har C++ program main naam ke function mein execution shuru karta hai. #include <iostream>, input/output library ko la deta hai, aur using namespace std aapko har baar std::cout ke bajaye bas cout likhne deta hai — yeh convenience poore course mein use ki gayi hai, halaanki bade real-world codebases aksar explicit std:: prefix prefer karte hain.

Compiling sabse pehle hoti hai

Jab aap run dabate ho, compiler (g++) ek bhi line execute karne se pehle aapki poori file ko ek binary mein translate kar deta hai. Agar kahin bhi koi type error ya syntax mistake hai, to kuch bhi run nahi hota — aapko output ke bajaye ek compile error milta hai.

Comments

Comments C aur zyadatar C-family languages ki tarah kaam karte hain: line mein // ke baad jo bhi likha ho use completely ignore kar diya jaata hai, aur yeh sirf isliye hote hain taaki baad mein code padhne wale insaan samajh sakein ki kuch is tarah kyun likha gaya hai.

Khud run karke dekho

Yeh raha ek chhota program jisme ek comment aur do cout statements hain. Neeche dikha output actually execute karke nikala gaya hai — text change karke khud bhi example ke neeche button se run karke dekho.

// This is a comment - C++ ignores it
#include <iostream>
using namespace std;

int main() {
    cout << "Hello, World!" << endl;
    cout << "Welcome to C++." << endl;
    return 0;
}
Output
Hello, World!
Welcome to C++.

Aage: variables aur types — fundamental types, auto type inference, aur const.

Practice exercise

Apne code ke upar ek comment add karo, phir "Learning C++ one step at a time." print karo.