Monday, November 25, 2013

[Tutorial C++] Basics of Programming Part 1

This would be the starting of basics tutorials for C++ aimed at helping beginners learn C++. The programs made in the tutorials, are made using Codeblocks which uses GNU GCC compiler.

If you have no knowledge about what is programming? then I do recommend that you read this first.

http://www.cppfuzz.com/2013/11/c-class-1-some-basic-concepts.html

http://cplus.about.com/od/introductiontoprogramming/p/programmers.htm

Required software

Before we can start to program we will require two things they would be a C++ compiler and a text editor or you can just get an IDE (Integrated Development Environment) like Codeblocks or Borland C++.

You can download codeblocks from here.

Writing your first program

The first program we will make will be a simple Hello World in which as most of you will know that we are going to print Hello World on the screen.

#include<iostream>
#include<conio.h>


using namespace std;


int main()
{



cout<<"Hello World";



getch();
}
 
Now compile and run it, if you are on codeblocks click the button which contains the play and build image.
 
If you did everything right then you will see a window come up in which Hello World would be written.




 So by now you will want me to explain to you how this stuff works. Okay then but we will not go in much detail.
 
Let's start then, first of all we have the header files iostream and conio.h which are a kind of dictionary for the C++ as it contains the commands which tell C++ what to do. While #include is the commands which add these header files to our program so next time whenever you are going to add a header file write "#include<>" without the double quotes and then write the name of the header file between "<>". Always remember to add your header files and it should be at the start otherwise your program will fail to work.
 

#include<iostream>
#include<conio.h>
 
 
Next comes up
 
using namespace std;
 
which is something that codeblocks users should add otherwise your programs would again fail to work.
 
Finally comes the main thing which is the main function
 
int main()
{


}
 
You always add the main parts of the program that is C++ user commands in it.
 
Now comes the two functions. The first one that is cout is used to print something on the screen. Remember all the text should go inside the double quotes.
 
cout<<"Hello World";
This is a function I will leave for you guys to figure out but I will explain it in the next tutorial. Though here's a hint for it, remove it from the program and you will notice something. If you don't then well you will have to wait till the next tutorial  :).

getch();
 
See you then in the next tutorial and until then happy coding. Also feel free to post any problems or your feedback in the comments below. Also visit http://bb.waratteka.net/  for more programming tutorials.

1 comment:

  1. The croupier uses a 온라인 카지노 protracted paddle manufactured from wooden, known as as|often identified as} a palette, to maneuver the cards and casino chips at the far ends of the table. Before the game begins the supplier shuffles the decks of cards. One of the gamers has to chop them earlier than they can be positioned into the dealing shoe. In contrast to Punto Banco described above, each the banker and the participant have some limited alternative of whether to attract a third card to their hand.

    ReplyDelete

Widgets

 

Copyright @ 2014 CPP Fuzz.