Click here to Skip to main content
16,017,100 members
Articles / Programming Languages / C++
Article

Tutorial 1

Rate me:
Please Sign up or sign in to vote.
1.00/5 (13 votes)
14 Nov 2000 82.3K   23   12
This tutorial has been made to give an introduction to new c++ programmers. Unfortunately their are many great minds out there but they don't have access to free and quality c++ tutorials. So this is the first lesson.

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

 <o:p>

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

 <o:p>

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

 <o:p>

 <o:p>

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>

 <o:p>

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

 <o:p>

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

 <o:p>

 

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.

 <o:p>

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

 <o:p>

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

 <o:p>

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

 <o:p>

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.

 <o:p>

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

 <o:p>

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.

 <o:p>

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”

 <o:p>

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

 If you have gained knowledge from this tutorial please make me happy.

 

Introduction

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralThis is an Example for you all Pin
Muheed Moosa15-Oct-04 13:39
sussMuheed Moosa15-Oct-04 13:39 
Generalright... Pin
alex.barylski15-May-04 16:10
alex.barylski15-May-04 16:10 
GeneralWorst one Pin
surendiran5-Nov-03 1:07
surendiran5-Nov-03 1:07 
GeneralAnother pat on the back + MORE ..... Pin
10-Oct-03 17:31
suss10-Oct-03 17:31 
Generalgood tut Pin
Jaygiri27-Dec-02 9:45
Jaygiri27-Dec-02 9:45 
Generalabout c++ Pin
12-Apr-01 22:08
suss12-Apr-01 22:08 
Dear sir
I need free c++ tutorial book by e-mail.
Can you send or can you give Web ID.
thank you
H.krishnamoorthy
ESCO
GeneralSome (small) comments Pin
AlexMarbus16-Nov-00 12:30
AlexMarbus16-Nov-00 12:30 
GeneralRe: Some (small) comments Pin
17-Nov-00 7:09
suss17-Nov-00 7:09 
GeneralRe: Some (small) comments Pin
AlexMarbus19-Nov-00 13:26
AlexMarbus19-Nov-00 13:26 
GeneralRe: Some (small) comments Pin
19-Nov-00 6:32
suss19-Nov-00 6:32 
GeneralRe: Some (small) comments Pin
18-Apr-01 9:16
suss18-Apr-01 9:16 
GeneralRe: Some (small) comments Pin
AlexMarbus18-Apr-01 11:27
AlexMarbus18-Apr-01 11:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.