tutorial,been,made,give,introduction,programm
Quick Search for:  in language:    
tutorial,been,made,give,introduction,programm
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
C/ C++ Stats

 Code: 451,578 lines
 Jobs: 558 postings

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for C/ C++.
Url Test
By Richard Creary on 8/27


Nice Console Calc
By Andrew Carter on 8/26


Visual Pi Hex 2
By jo122321323 on 8/26


Cascade Clone v1.0
By Paulo Jorente - aka JungleBoy on 8/26


Bubble Sort Algo
By d1rtyw0rm on 8/26


Copy File I/O
By Olivier Bastien on 8/25


Visual Pi Hex
By jo122321323 on 8/25


Click here to see a screenshot of this code!ShortCutSample
By Massimiliano Tomassetti on 8/25

(Screen Shot)

AnPMoneyManager beta
By Anthony Tristan on 8/24


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

C++ Intro...

Print
Email
 

Submitted on: 9/20/2000 10:22:56 AM
By: Amin Patel1 
Level: Beginner
User Rating: By 52 Users
Compatibility:C++ (general), Microsoft Visual C++, Borland C++, UNIX C++

Users have accessed this article 43224 times.
 
(About the author)
 
     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.

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
1) You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.

C++ Intro…                                       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++.

 

I plan to write more tutorials when I can dedicate some time after school. If you like this code please give me a good message. I do need messages occasionally like “Thanks”, with all the pressure I face from school. If you have gained knowledge from this tutorial please make me happy.


Other 3 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this article(in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
9/20/2000 1:10:16 PM:Ian Ippolito
Amin, Great tutorial--I think beginners will find it very useful. Just to let you know, you can format your tutorial using HTML tags...this will let you add coloring/spacing, etc. Keep up the good work! Ian PSCode Admin
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/20/2000 5:13:38 PM:Kamran
Wow, this tutorial really help me understand some things I didn't really get with the "Hello world" program.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/21/2000 7:47:36 AM:Amin Patel
Dear everyone, thanks for making me happy. Ian Ippolito I have now incoperated a new html layout and design. Since people made me happy, I even added colour coding.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/4/2000 5:45:37 PM:alaa
this code contains errors: i think that any programmer in c++ should know that the function int main() should return a value. the good listing should be like this: int main() { /*YOUR CODE*/ RETURN 0; //or any integer } OR void main() { //YOUR CODE } you should learn to people what is true.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/5/2000 7:30:53 AM:Amin Patel
return 0; would be appropriate, had I taught data types. Thanks for noticing. When you learn data types(int, float, void), it is a good time to explain.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/8/2000 7:03:25 AM:alaa
then, please do not use int , and use void.(it will not generate a warning)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/8/2000 9:44:45 PM:Oliver .j. Malik
This tutorial is really informative for its size! It's MUCH more concise than the SAMS
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/16/2000 8:23:47 PM:Kory
you forgot << endl;
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/17/2000 7:32:31 AM:>Link
ok I NOW know how to program in c++, thanks to this tutorial, and many other i found on the internet. I probably cannot 'speak' here because i am an 'amuture': I compiled and wrote (other way 'round!) this here little program, and it works like my bike chain, after it's been oiled! THERE IS NOTHING WRONG WITH IT! Although feel free to dissmantle and destroy my comment, as it is based on: 'it works, i don't care' atitude.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/19/2000 5:38:18 AM:Craiguess
This is so KooL man! but only one problem... When i tried to do the exact instructions in 1st box where it says; 1. <iostream.h> 2. 3. etc. i typed it exactly into my colpiler and it didn't work.. it wouldn't compile because it came up with one error; The first line..
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/19/2000 8:10:21 AM:Amin Patel
Craiguess, Since problems due to different compilers and compatibility were occuring the 3rd tutorial starts with and addresssing of the problems, check it out at: http://www.planetsourcecode.com/xq/ASP/t xtCodeId.805/lngWId.3/qx/vb/scripts/Show Code.htm
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/19/2000 11:06:31 AM:zoka
This progam is perfect. Also statemant
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/20/2000 6:47:49 PM:arra
in place of <<endl; you can also utilize \n
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/20/2000 6:49:32 PM:arra
in place of <<endl; you can also utilize \n"; [which tell cout to put a new line after these final two characters. ][good work,& good explanations]Also it is allways necessary to return a value back to main when it is initiated, to signal to the complier that the program has run its course, ie.. return void or return 0.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/22/2000 7:51:51 AM:Amin Patel
Thanks arra but I wish to do that once data types have been explained, but since you have mentioned it, ppl before you close your program with the } brace plz. type: return 0; It is a good programming practice, it tells the compiler that you have succesfully terminated.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/24/2000 11:07:56 AM:CooLViruS
I like the way you explain everything...although there are some mistakes...but don't you think that it's too simple?I believe you should add some more (commands,functions) to the tutorial in the place of the pronouncing part. I don't think that anyone is really interested in that.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/24/2000 11:20:59 AM:CooLViruS
It's a "sweet" tutorial but shows almost nothing. It would make a lot of people happy if %d was explained and if you would put an exaple of it.The way you explain is good.(I believe that the pronouncing part is useless).It's better that no mistakes are found in tutorials.Especialy the ones for beginers.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/25/2000 12:20:59 AM:ah
Thanks
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/25/2000 12:59:39 PM:Amin Patel
Hey Virus, actually the pronouncing part only helps you communicate the code to your friends, I know many people who even pronounce it wrong. Anyway thanks for XPRESSING your self. Regarding 'mistakes' plz. refer tutorial 3, different compilers, different styles, different ppl. You know what I mean.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/25/2000 4:49:16 PM:XIX
Great JOB DUDE! C++ can be fun when u have a fun way of learning it.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/31/2000 8:52:25 AM:karthik
hey, u're tute is really good, I am new to this & I really would appericiate if u can keep this up.& can u tell me any websites or tutorials which is good for a beginner like me.(from the scratch) it would be greatful, thanxz. keep up the good work, people like me depend on u.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/10/2000 9:01:30 PM:arra
in%2Bplace%2Bof%2B%253C%253Cendl%253B%2B you%2Bcan%2Balso%2Butilize%2B%255Cn
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/19/2000 1:36:34 AM:Biofreak
Good work ;o)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/23/2000 1:44:35 AM:Confined
what else do you know how to do in c++, Amin?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/1/2001 7:52:12 AM:Matt Savage
great tutorial for a first time user! thanx alot d00d!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/3/2001 2:29:28 AM:HELLRAISER
I get an error when i compile it.. error spawning cl.exe can you help me....
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/7/2001 3:10:02 PM:mike
Thank you Amin,it is sometimes hard to find a person with a good heart who will take the time to share knowledge,Ihope your lifes endevours are pleasing and blessed...thanks
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/7/2001 3:14:37 PM:michael
Thanks Amin, for taking the time ans having a good enough heart to help others..thats a good quality in a person I hope you are blessed for your sharing of knowledge,,thanks
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/18/2001 6:44:21 AM:Amin Patel
<Confined>: The 2 links provided by me previously have changed, you can directly reach the two sites using - Tutorial 2 ___________ http://www.planetsourcec ode.com/vb/scripts/ShowCode.asp?lngWId=3 &txtCodeId=773 Tutorial 3 __________ http://www.planetsourceco de.com/xq/ASP/txtCodeId.805/lngWId.3/qx/ vb/scripts/ShowCode.htm
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/13/2001 7:52:34 PM:kskinner
Very nice! I am new to C++, and did actually understand what you were trying to get across. Don't let the critics get to you, you are providing a good service to us all!!!! Thanks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/16/2001 10:57:12 PM:Stanley freifeld
Very informative! Good for a newbee to be exposed to. Thank you
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/28/2001 3:21:28 PM:Dave Dyer
Hey Amin, very nice work on the post, it was explained for beginners very nicely,and it's not too much to digest. It's stuff I already know, as I am fledgling programmer, but the way you write it makes it incredibly easy to understand. I look forward to reading your other posts, please keep them up! As for the
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/28/2001 3:22:11 PM:Dave Dyer
Hey Amin, very nice work on the post, it was explained for beginners very nicely,and it's not too much to digest. It's stuff I already know, as I am fledgling programmer, but the way you write it makes it incredibly easy to understand. I look forward to reading your other posts, please keep them up! As for the "errors" in the code, there are about 25 different ways to write this little tidbit of code, none of which are "right" so keep your opinions to yourself please, so as not to confuse the people who really need this code, the beginners, like me. Thanks again for the post.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/19/2001 9:32:22 PM:eagle
Well as long as you return 0 you don't get any warnings. Great beginning code man. I'm trying to get C down packed so it's easier for me to mess with Linux stuff.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/23/2001 7:29:27 PM:Lord Nova Ice
Nothing Special here, but its good for begginers(just not me) in c/c++ i would like to see more examples with borlands C++ Builder for windows apps.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/30/2001 7:19:57 AM:xiaodong
good
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/31/2001 7:34:51 PM:Cybrgoon
Well, Amin ... a very nice and well done tutorial(spoken as a true beginner.) I have a request though: When you put code examples into your tutorials, could you comment the portions of the code that are
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/6/2001 9:39:06 PM:Soheil Yasrebi
That was just great, because this was thefirst thing I ever read about the C programming and I learned someting from it. Anyway I had a quetion to ask that what country are u originally from??!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/10/2001 6:34:47 PM:Neil Ramsbottom
I am sure that I have seen this tutorial on www.codeproject.com, but with a different authors name on...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/26/2001 6:50:50 PM:Prytanis
The water has been tested and it is not as frigid as I thought it would be. Thanks Amin, well done
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/27/2001 1:48:58 PM:Amin Patel
To: Neil Ramsbottom Tutorials (1-3) of mine exist on codeproject too.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/10/2001 9:09:15 PM:joahnna
I am a true beginner. at least learning the basic is something! Thanks!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/1/2001 9:02:20 PM:Deryck H
Thanx dude, that helped a lot. Now I'll take your other 2 tutorials.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/11/2001 10:40:32 PM:Akuma no Houkon
It was a nice tutorial, but did not go in areas that I am in need of assistance in, I am trying to learn C++/VC++ and I have been programming for 8 years and have used every style of language avialable except for C++ style lanugages and asm. I try and learn this, even with your tutorial, and it just goes in one ear and out the other (probably because I have mastered all versions of VB, and Basic, HTML, ect. so the C++ style just inst sinking in, can someome PLEASE HELP. LeadProgrammer@CrypticDesigns.com Thank you.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/24/2001 10:18:21 AM:n
n
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/12/2001 4:37:25 PM:traceywindsor@hotmail.com
This is an awesome start to tutorials, please keep it going. If you don't mind, I will be suggesting this tutorial to all of the CPSC100 students at my school who are learning C++ for the first time. This is an excellent example, with none of the tech-styled language. If I had read this when I first started programming, I'm sure that I would have had a much better understanding over the first few lectures. Thanks again! Tracey
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/4/2001 4:36:48 AM:Chris
Great! =) For Visual C++, line 2 should say
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/4/2001 4:38:48 AM:Chris
PSC messed up that last line. I meant to say for Visual C++, line 2 should say void int()
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/7/2001 11:26:17 PM:Brett Birkett
If this tutorial is for beginners, why does the first tutorial not show how to compile and link?? Compilation of source code is assumed knowledge i noticed. - Brett.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/11/2001 3:01:26 PM:imn0thing
dude, i dont know how you got so many good ratings. you can read the first 4 lines of any C++ introduction book and learn more than this tutorial. your explanations don't make much sense, and it only introduces a single, standard library function (cout). this is ridiculous.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/2/2001 5:32:16 AM:ji
i haven't even tried to usethe code yet, or read the tut all the way, but i can tell that this guy did some good work for a beginner's tut. i'm sure most of the inspired c coders that go on the greener pastures will forget this code and perfect thier own ware. so as far as the previous post, i'd have to agree that 'urn0thing'.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/10/2001 5:52:32 AM:Telegeek
It really helps a N00b
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/17/2001 3:55:54 PM:Y-NOT
Thank you, I have been looking everywhere for information like this,it is GREAT!!!, there is one other thing no one has helped with, (remember) I am a beginner, ? Where do you start? MS-DOS, Notepad, redhat,....ect....?????
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/21/2001 8:58:22 PM:Bal Canete
Hi Amin, 'am very much confused of C/C++ until I've read your tutorial. Thanks a lot man, please publish some more.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/16/2002 11:17:39 AM:Ramadan
Excellent job!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/21/2002 4:46:59 AM:Keolebogile Mokolopo
Your intro of C++ is very good,but i'm wondering if you can help me with the project i have to do. my email is:2001017546@wwg3.uovs.ac.za If you are willing please reply.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/21/2002 4:48:52 AM:Keolebogile Mokolopo
It's very good,i'm impressed
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/9/2002 6:10:26 AM:uv
really helpful
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/8/2002 8:07:36 AM:Clif
Hey man! Just a quick one to say great job & thanks. The only experience I have had is in BASIC (remember that?) and your tutorial more than helped open a new door for me. It was very basic, but got the point across. Also, by reading other tutorials as well as comments from other programers, there is more than one way to skin a cat. The whole experience was very enlightening to say the least. Hope to see more tutorials from you in the future, and thanks again for sharing your knowlege on this one!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/5/2002 5:40:15 PM:john sheridan
i typed in those first couple of lines, tried to run them, and it said "102 errors found". i don't even know if thats possible cuz it doesn't even have 102 characters...wierd...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this article has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular article, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | C/ C++ Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.