Thursday, 6 June 2013

Learn C++ Step by Step for beginners < PART 3 >

In the previous tutorials you would have seen the below code , In this post I will help you understand this code



#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}


First I would like to tell you how C++ or any programming language works

If a computer is a worker and you its head , then the programming language is the instructions you give it .

At first computers could only understand instructions as 0 & 1 . Now the Compiler ( Code :: Blocks ) 
will convert codes in English to Machine code ( 0 & 1 ) for you  

Now let be start explaining what each line in the code means




#include <iostream>

This line tells the compiler to include the file which has already be codded for you
This <iostream> lets you print lines you want


using namespace std;


This tells the compiler what and all files are needed to be included for the library files ( iostream )


int main ()


Well this is the start of the program , and the execution will begin from here

cout << "Hello World!";


This is the code which will print the required lines in the console ( "hello World !")
And this is why you need the include statement , as cout is a part of iostream


return 0;


This is where the program ends , if the compiler encounters this statement , even if there are more statements the program will stop


;


This is the semi-colon and depicts the end of a single statement


Well this concludes the 3rd part of the tutorial , and i hope you have understood everything

If you have any doubts please comment or use the Contact Me page 

Thank you ..............





 


No comments:

Post a Comment