Intro
we know computer just understand binary language(machine code) and it's really hard or we can say impossible to do work on binary language for human(I mean for us :) ). So, we need a suitable language so we can easily communicate with computer.
For example if you are form other country and you don't know the English language and you really need to communicate with someone who just speak English at this point you need a translator. Similar in case of computer you need a translator to communicate with computer and that translator is know as complier
Complier is more then translator it's help to find error in your code at compile time but in some case compiler can't be able to find the error,
for ex:
Let's we have to multiply output a and b but we did output as (a + b). In this case complier doesn't know you want to multiply, these type of mistake we can catch at run time.
next is Ide : In case of ide we don't need to compile and run separately we have to just click on button that help out to do both for example in vs code we just have to click on play button.
Now we are going to start writing hello world in c++.
Hold on before we are going to start I hope you all already know that what is extension and extension of c++(.cpp)
Let's think about what we do when we start with flowchart ( I hope you've little bit knowledge about flowchart if you don't then Click here ) come to the point we use start Terminators in flowchart as same in C++ we should need
int main(){
}
//as *start Terminators*
middle bracket shows all inside code we going to write is part of int main
int main(){
cout<<"hello world"<<endl;
}
we can't print Hello world without double quotes(" ") because if don't then compiler can't able to understand it is string and they will give an error.
The "c" in cout refers to "character" and "out" means "output". Hence cout means "character output"
cout : cout is an inbuilt object that helps to display the output to the standard output device. << is the insertion operator (in simple word it's tells that data have to go outside)
If you run this code then compiler can't be able to understand. So, if you are using something inbuilt then you have to include that file in current file and that file is: #include
#include<iostream>
using namespace std;
//and we added namespace std bcs we don't need to use std again & again with cout(just ignore it for now)
we did code break down now you can run this code in your compiler.
#include<iostream>
using namespace std;
int main(){
cout<<"hello world"<<endl;
//we can use "/n" instead of endl both are same
//
}
and you will get hello world as output.
endl or "/n" : function is used to insert a new line character and flush the stream
;(semicolon) is like full stop in code we should use ; in end of line other wise we will get error.
Do one example make sure you read carefully
//What is the output ?
#include <iostream>
using namespace std;
int main(){
cout << zealycoder ;
}