tutorial,been,made,programmers,Unfortunately,
Quick Search for:  in language:    
tutorial,been,made,programmers,Unfortunately,
   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



 
 
   

Tutorial 3

Print
Email
 

Submitted on: 10/18/2000 4:04:30 PM
By: Amin Patel1 
Level: Beginner
User Rating: By 49 Users
Compatibility:C++ (general)

Users have accessed this article 34532 times.
 
(About the author)
 
     This tutorial has been made for new c++ programmers. Unfortunately their are many great minds out there but they don't have access to free and quality c++ tutorials.

 
 
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.
Tutorial 3- By: Amin Patel     About Me  
c, c++, c__,tutorial,been,made,give,introduction,programm

 Planet Source Code -                      Start with a prayer to God, that you “Succeed in learning C++"

 
 
Advanced Search

 

Previous Tutorials:
Tutorial 1 Tutorial 2


Only at PS Code

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

 

Thank you for coming to Planetsourcecode 
Style: In the first tutorial some people had pointed out that I had not declared main() to return void, this is no longer a standard expected from programmers. Get main() to return int & simply return 0; as the last line in main().
<-- content_start-->

Note: According to the latest standards <iostream.h> is not required it can be simply written as <iostream>, with the standard code that shall be used through out the tutorial (I hope!).

If the standard code in the tutorial does not work on your compiler and you still wish to use <iostream> instead of <iostream.h> just add a line

using namespace std; 

& if this does not work you have an old compiler which cannot work with these standards.

 
 <-- Begin Search Code -->
    Now Pay attention, with a little explanation and review of the first tutorial we shall proceed. Some people requested for the theoretical details.
- Preprocessor 

Preprocessing is done when the #include command is used to add header files. The actual preprocessing is done much before the compiler reaches the code section of your program. The #include command is one of the possible actions of preprocessing.

All Preprocessing is done with #(Hash/Pound Symbol)

- #include

This a directive to the preprocessor, with the help of the " Include Hash/Pound " the file after the directive s read.

Eg: #include <filename> or #include <filename.h

- IO

When generally the topic of input is raised, the first thought that comes to a person's mind is that input means input from a keyboard, mouse, joystick, etc and is outputted to a device such as a disk, monitor (screen) or printer & this thought is technically correct; in explaining the concept of input-output.

- Input is done in streams of bytes or a sequence from devices (e.g.. keyboard, mouse, joystick, etc). 

-In Output bytes flow from the output devices.

A program is divided into bits, bytes, a byte may represent ASCII characters.

The C++ iostream library has many I/O capabilities but for now we are only concerned with a few.

The <iostream> header file defines the cin, cout objects.

 


 I think the theoretical explanation of the beginning of a program should be enough for now. Let us now get to the 'real' juicy part of programming. (Duh - Writing the code)

- 2 Input/Output Objects ( In relation to the tutorial)

cout (It ain't pronounced as Cowt, its pronounced as C  Out)

The cout operator has already been explained in tutorial 1 but here is a brief review + additions.

cout is a keyword, which is exclusively reserved for C++ defined purposes. It is used to output data info to the standard output device.

cout<<"This is Text"; 

By the way Comments( // ) have been explained previously.&nbs; // p;

// << is  known as stream insertion operator. 

// "This is Text" is displayed to the screen.

//The << is also known as left shift operator, it is used after the cout command.

cout<<text; 

//The data from a variable text is displayed to the screen.

//Variables have not yet been explained at this point.

 

 

 

   
Now to explain the next topic cin & datatype (int), we shall attempt to understand by studying a simple program. - Adding 2 integers

Non Standard Version

#include <iostream>

int main()
{
int one, int two, int sum;
cout<<"Please enter the first number"; //Requests for first integer
cin>>one; //accepts first integer

cout<<"Please enter the second number"; //Requests for second integer
cin>>two; //accepts second integer.

sum = one + two; // one & two get added and the value gets assigned to sum.
cout<<"The sum:"<<sum; //sum of 2 int's is displayed

return 0; //program has ended
}

Standard Version

#include <iostream>

using std::cout;
using std::cin;


int main()
{
int one, int two, int sum;
cout<<"Please enter the first number"; //Requests for first integer
cin>>one; //accepts first integer

cout<<"Please enter the second number"; //Requests for second integer
cin>>two; //accepts second integer.

sum = one + two; // one & two get added and the value gets assigned to sum.
cout<<"The sum:"<<sum; //sum of 2 int's is displayed

return 0; //program has ended
}

<-- content_end-->

_______________________________________________________________________

  If you like this code please give me a good message.  If you have gained some knowledge from this tutorial please make me happy, by giving me an “excellent rating”. That's all I ask.

_______________________________________________________________________

 Tutorial 3 - By: Amin Patel

 

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

   C++ - Tutorials

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.


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
10/22/2000 6:14:48 AM:Picklezz
Can't yu give a tutorial in starting making your first app?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/22/2000 7:43:37 AM:Amin
Refer tutorial 1
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/25/2000 10:50:33 PM:Kuvrio
It would be grate to have your 3 tutorials on a ZIP file to download once.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/26/2000 4:37:42 PM:Leprechaun
I think this is a good idea, I wish I had found something like this a year ago. But, me being a smart aleck, I have to say that you should have a \n at the beginning of your ouput, and a space at the end like: cout <<
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/27/2000 1:12:16 PM:Amin Patel
Ok, from next time I shall start. Thanks for the comments ( Zip and /n+space)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/29/2000 11:31:16 AM:Treker
Today's programming standards in C++ using IOSTREAM are that you use an endl, not a \n to mark a newline.<BR> cout << "Blah..." << endl; would be the ideal format.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/30/2000 12:14:03 AM:Amin Patel
Ok
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/31/2000 3:46:51 AM:R 2 k
I really love these tutorials they make me love c++ now.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/4/2000 9:04:02 PM:mud
its easier if while using cout <<endl <<...; you also incorporate the \n command where convenient. (i.e.: cout <Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/4/2000 9:06:48 PM:mud
however, it can be confusing to use both so itd be easier to learn if you just you endl (\n versus '\n' can be confusing)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/6/2000 6:18:48 AM:Daniel Krusky
These Tutorials are really good. Do you have any knowledge of NetBIOS ?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/30/2000 3:32:22 AM:mike14mon
THIS IS GREAT!!! thanks im new at c++ very new ive spent long aggervating days reading c++ in 21 tuts, im looking foward to more articals from you ...thanks again
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/4/2001 10:57:50 AM:Smiley
hey i love these tutorials but im having a problem. when i run these once it has ended it closes out really fast and in this one i cant see the ending number and in the first tutorial i couldn't see anything cause it closed out so fast. how can i make it stay open?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/21/2001 11:49:18 PM:Ryan
Don't worry, that happened to me when I first began learning. Here, try this. <-- start code --> #include <iostream.h> #include <conio.h> int main() { //print to screen cout <<
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/10/2001 4:27:43 PM:Bhavendra
Hi Amin, Thanks very much and putting ur effort on C++ and sharing ur knowledge. It's very helful for me I don't know anything abt c++ now I'm understand how to write programm in C++. If u have any goodu documents for beginners please let me know. thanks onece again. Wihs u all the best.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/24/2001 12:22:08 AM:FTWJFIA
About the program closing realy fast when run - I had this problem too. I did some research and found a solution add: #include <conio.h> and at the end of your program add: system(
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/24/2001 12:23:42 AM:FTWJFIA
Sorry. At the end of your program add: system("PAUSE"); Happy Coding!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/11/2001 3:13:28 PM:imn0thing
with your three tutorials combined, it makes the worst introduction to the language i have ever seen. it is not even good coding practice to declare multiple variables on a single line. but if you do, it should be like this. int one, two, sum; not int one, int two, int sum;
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/16/2001 2:22:44 PM:vorticon
well simple and easy ot understand but there should be more explanation in the 3rd tutorial. now a VB proggrammer is a begginner C++ proggrammer thx
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/16/2001 4:02:50 PM:MerDeNoms
Also If you want to use any of the
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/16/2001 4:04:03 PM:MerDeNoms
If you want to use any of the "system" commands, you will need to add the directory "#include<stdlib.h>" That will allow you to use the commands: system("pause"); <---Pause the program untill you hit enter. system("cls"); <---Clear Screen wich is great for cleaning up screens on menu driven programs.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/2/2001 5:57:30 AM:ji
thanks amin. great work! and to the intellectually impared 'imn0thing'... once again, i think that i can speak for most of the beginners read mr. patel's works... you're absolutely right... 'youAREn0thing'.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/21/2002 7:51:54 AM:Deepsmeg
II must say that I agrree w/ imn0thing. I bought sams teach yourself C++ in 24 hours, and the first 3 chapters have given me a far clearer understanding than these tutorials.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/18/2002 11:41:09 PM:zenthor
i don't see why you guys are compareing a free tutorial to a book you payed for also whne i compile these tutorial with vc++6 i get a debug error: Loaded 'ntdll.dll', no matching symbolic information found. Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found. The thread 0x5B0 has exited with code 0 (0x0). The program 'C:\Documents and Settings\zenthor1\Desktop\ctut101\Debug\ helloworld.exe' has exited with code 0 (0x0). how do i fix this?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/29/2002 5:39:23 PM:CodeLearner
Excellent tutorial, thanks. :)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/24/2002 4:23:48 AM:Whittal
I love these tutorials. keep 'em coming. They are exacly what i was looking for. Nice and easy to understand and you explain everything.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/11/2002 8:16:50 PM:Jaimin Patel
How long does it take you to learn C++ if you go by the tut's?
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.