Make your own free website on

C++ Intro (Part 1) by Amin Patel

Before you write your first program. Start with a prayer to God, that you “Succeed in learning C++”. 

Now that all your hopes are high let us start. Please enter the following code exactly as shown, without any questions. (This is to inform you that the explanation will follow after the code.) 

  1. #include <iostream.h>
  2.  int main()
  3. {
  4. cout<< “ What you do is what you get”;
  5. }

Although this may sound strange, once you compile this program you are a programmer.

<Warning: The numbered indentation is not to be included with the code while typing. It is only for your convenience>

Now let us read the first line. You read it as “Hash/Pound include eye-oh-stream-dot-h”

Iostream: Input Output stream. Don’t learn the definitions they automatically come to you.

 You don’t pronounce the brackets while reading it loud, but is it a part of the code.

.h: Dot h files are known as header files. We place them in the beginning of the source code; it is like adding a DVD-Player to your deck. You don’t create .h files for now, nor would you add a DVD-Player to your deck each time you want to use it.

Iostream.h: Ok now you know what iostream and dot h stand for. If the terms input & output haven’t shed any light yet, keep reading. Iostream lets your program accept info/data/content or publish the same to the screen.

Wait we are still on the first line. Read the first line of source code again!

“Hash/Pound include eye-oh-stream-dot-h”

The Hash include is the standard form for telling the compiler that you want to include the Iostream.h file.

Now on line 2 we have int main().  Int is read as integer, read main() as main function. Without line 2 your program cannot work. On line 3 and 5 you have these {} braces.

Between the 2 braces all your code fits in. Make sure you enter line 4 exactly as it is. Pay attention to the punctuation.

Cout: See cout – It is the command with which you display text onto the screen

The << on line 4 is the redirection symbol produced on most keyboards by holding the shift key and pressing the comma key twice. The text in between the quotation marks, in the case “What you do, is what you get” is what shall be displayed onto the screen when you run the program.

Line 4 ends with a semi colon, don’t forget to type that, almost all c++ statements end with that. Now you may finally link, build and compile the code. Now you receive a message on a black terminal (Dos like): “What you do is what you get”

Congrats - You are now officially a programmer and that too c++.  

Add your tutorials to this site Mail Me



GauravCreations's Store / Home / Register / Awards / Opinions / Downloads / Query

Linux Hosting India | Linux Forum

Copyright © 2001-04 [Gaurav Creations]. All rights reserved