Lets Write our First Program here,
#include<iostream>
using namespace std;
int main(){
cout<<"Namastey!"<<endl;
return 0;}
Explanation!
let’s break it down step by step:
#include<iostream>
using namespace std;
This lets you use elements from the std (standard) namespace directly. Without this, you’d have to write std::cout instead of just cout.int main(){
The main function is the entry point of every C++ program. Execution starts here.cout << "Namastey!";
cout is used to print output to the console. The << operator sends the string "Namastey!" to the output stream.Don’t forget the semicolon ; — it marks the end of the statement.
return 0;
This tells the system that the program executed successfully. Returning 0 usually means everything went fine.Now, to compile and run this code using g++ (GNU C++ compiler):
Open your terminal.
Navigate to the folder where your fun.cpp file is located.
Compile it using the command:
g++ fun.cpp -o fun
This tells g++ to compile fun.cpp and create an executable named fun.
Run the compiled program:

0 Comments had been done yet:
Post a Comment