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.
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.