This is you first basic programming day
in this day we will Understand Compiler :
What is a Compiler ????
A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code). The most common reason for converting a source code is to create an executable program.
Executable files are the file having the extension .exe at the end .
If you are a gamer while installing a game you run an .exe setup,
it is same as that to execute a program , usually a game is also programmed :)
1)Now open your codeblock.
2)You can see a link of New Project .. click it .
3) now after next , it will ask program for C or c++ ? choose c++ as we are using c++, then choose Console Application.
4)now there exist where to save that file , and on the top Text Bar (the white bar)
it is empty write a name of the program and store it on a specific location where you want to create your work space.
5) now you will see at the left corner Workspace Below that it will be the name you gave to your program , click on that name and there will be another sub folder file as main.cpp.
Click it
6) here .cpp is the extension of c++ , every program of c++ has extension of cpp :)
7) now it will pop up the first program.
it looks like
now here you see.
#include<iostream>
this is know as a header file ,a header file is responsible of implementing other files which perform specific task '#' this represent that you are going to open a directory of <anyname> in diamond notation you write the name of the specific file. So what you're doing here is that ,
You are implementing a Iostream(Input /output streaming ) Folder using Include command ,
2nd line ) you see using namespace std; Leave it here for a while as it is intermediate level .
Int main()
now you see written int main here
Int stands for Integer, while Main is you can say the Brain of a Program, which performs everything in it . So the every code you write is to be written inside it. it is know as a main function. since a function (which perform a specific task)hind is to have parenthesis right next to its name like main(). it can also be thought as main is the opening of a program .
{ } curly braces :
these curly braces are know as the body of main function , in this whole the body of you function like your body all the body comes right down to your head , means your main part of your body.
these represent the opening and the closing end of a body.
cout:
cout stands for compile output(a standard output streaming ( stream is flow of data representation) ) , it is used to display the output of the specific program.
the next to cout you see "<<" insertion or put to operator ... This usually directs the content of variable from right to the object at its Left .
as anything " Hello world " written in "" format followed by cout<< prints out exact the same as it written. while to display multiple cout you use "<<" again and again after every statement e.g
cout<<"Hello"<<" World!"<<endl;
here the
endl:
it is to jump or finish the line you are in and go to the next line
;
a terminator :
"; " stands for a terminator , it is used to terminate every line of code, it is at the end of all the codded lines, it usually used to terminate that specific operation, function.
It is the most important and basic mistake in programming.
return 0;
you can see return 0;
as in the function you wrote "int main()" it has a datatype before the function main() which is int : it represent afte completing the function it will give you a value in integer formate Usually to get that value return Integer; is used . it is used also to freeze the ConsoleApplication such that you can read the code .
Now Compile and Run your Program :
now after running
Now you can see on the black windows you statement which you write in the "" quotations and
a space of a line due to endl;
This is your 2nd day task :)
No comments:
Post a Comment