Decompiling First C++ Program :: DigitalStage Blogs

This small article might be a huge step towards someone's future. This article will tell you how to write your first program in C++. I am going to show you the program and then eventually describe each components of the program. First could of videos in my video tutorial series is designed to show you the same. You can visit my videos section if you are more comfortable learning from video.

 
Requirements: 
C++ Compiler installed on your computer 
Some understanding of how to compile your program 
 
If you have not then please have a look at my first article which explains how to install the compiler and work with some basic compilation instructions in windows.
 
Alright enough said. Here's the code for your first program in C++, a conventional Hello World. 
#include<iostream>
using namespace std;
int main()
{
  cout << "Hello World" << endl; 
}

Alright, there you have it. Now let's dissect this little piece of code.

The first line is:

#include<iostream>

This is the preprocessor directive for this program. Anything that starts with a # is called a preprocessor directive in C++. It means that they are processed before compiling the actual program. Whatever is defined after # is done as preparation for program compilation. In this case we are including a file named iostream in our program that have standard defination for input and output and it is a library file that comes when you installed the compiler.

Next you have

using namespace std;

Here you are using something called a namespace  called std in our program. As you go on becoming advanced programmer you will properly understand what that is. You just use that for now.

After that the program starts with 

int main(){ }

This is called a main function. A C++ program always starts with a main function. The program will start the execution from there. This is the most essential part of the program.

In next line you just print out

Hello World!!!

which is done using 

cout <<

command. The endl means end line which basically says that in the output screen whatever output is going to be there, just put it in the next line. Play with the output to know about this more.

So, there it is... Your first C++ program. Welcome to the programming world!!!

Other Articles:

someImageHello everyone,

This is a very basic tutorial that involves on showing you how to get started with writing on C++ programming languages. I have a complete video on this. You can find it here: Getting started to C++.(Opens in new window).


Last modified: 11 years ago By: Suzzett

Let's say hello to C++ programming world:
#include<iostream>
using namespace std;
int main()
{
  cout << "Hello World" << endl; 
}

Last modified: 11 years ago By: Suzzett

This article is a bit of a explanation for my third video in C++ tutorial series. I will explain what are variable and data types in C++ and what you need to know about them while programming. So, let's get into it.

You can get to video here


Last modified: 11 years ago By: Suzzett

Hello Guys, I have had a lot of peoples coming to me asking about command line tutorials or at least have a little bit of understanding of command line so that they can get to my C++ programming tutorial series. So, this particular article is dedicated to those proples having trouble understanding why we use the Command Line Interface or otherwise known as CLI. I hope you will be able to make use of this tutorial to kick start your improved knowledge for computers.


Last modified: 11 years ago By: Suzzett




Comments:

Please login to post your thoughts!
 

There are no commnets yet!
 

Login

Username:
Password:
Don't have an account?
Register here
Register

Subscribe Youtube



Network DigitalStage.org


Some interesting stuffs