This is the tutorial where we really get into programming. Input and variables are the essence of programming. In this tutorial you will learn how to get data from the user and use variables. You will learn the types of variables there are and how to do basic math with them. At first, this may seem boring and pointless, but you have to learn it, and it should go quick.
Basic Input
When you are making a console application, here is how you should get user input. Some of you may have guessed it, you use c[b]in[/b], of course, the 'c' meaning console and the 'in' meaning input, like 'cout'. So, here is a basic code, where the name of the variable x. cin>>x;
Defining Variables
A variable is what you guessed, a number or piece of data that will vary.
The diffrent types of variables:
bool - true or false
int - whole numbers
char - character (a, b, c, etc...)
string - multiple characters (words, etc..)
float,double - numbers that can have decimals
When deciding what type of variable to use, think about what kind of data it is going to be storing and remember that some data types use more memory than others, however most of your applications will use less memory than you have. To declare a variable, write the type of variable, then the name.
Examples:
int myInt = 7;
char thisChar= 'a', otherChar = 'b', char newChar;
string password= "password";
Syntaxes
Notice how I always had the first word not capatalized, but I capatalized all the other ones. You can also define more than one at a time, and you dont always need to set the value in the begining. Also, when you use a char, use a ' and for a string a ". Try to give your variables meaningful names.
Math
This is really the heart of programming, math! For now, we are going to be doing some simple arithmetic.
The basic math functions are:
+ = addition
- = subtraction
/ = division
* = multiplication
There are a bunch more, but that is all we need for now.
Go out and make a program!
Now that you know some of that basic stuff, try making a program, and dont be afraid to ask for help on http://www.syschat.com!
Chris Silop - http://www.syschat.com!, Computer Forum
professional maid services Glencoe ..#5 All your hardware components like Printers, PCs etc come... Read More
This is intermediate level SQL scripting article for DB Administrator,... Read More
Microsoft CRM was designed to be easily customizable. Microsoft CRM... Read More
Microsoft released Service Pack 2 (SP2) for the Windows XP... Read More
Microsoft PowerPoint has dramatically changed the way in which academic... Read More
The major reason I recommend getting your hands on real... Read More
The first thing that you will notice about Linux Red... Read More
Follow the steps below to quickly design, generate, and deploy... Read More
When you buy a computer, it most likely comes with... Read More
You have gotten those E_Mails buy software at deep discounts.... Read More
With many manufacturing shops heading over seas in favor of... Read More
It is possible that if one avoided all sources of... Read More
When you double-click a layer in the Layer Palette, you... Read More
Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More
The research in the field of Natural Language Processing usually... Read More
The Internet is reshaping every form of communications medium, and... Read More
Now that spyware is the single most dangerous threat to... Read More
Bill of Lading is required report for Logistics and Freight... Read More
The intentions of this short tutorial are not to teach... Read More
Although we don't know whether Microsoft ever envisioned such a... Read More
Looks like Microsoft Great Plains becomes more and more popular,... Read More
During the years of our consulting practice, which comes back... Read More
If there still are few unprotected computers left, I haven't... Read More
Software development is a risky business.Many software developers are barely... Read More
Microsoft Business Solutions Great Plains is very popular ERP platform... Read More
last minute cleaning help Lincolnshire ..It's all about turn times in the eMedia industry! The... Read More
C++ Function templates are those functions which can handle different... Read More
Costs of fleet maintenance software can vary widely. It is... Read More
You turn on your computer, and it doesn't look quite... Read More
So, you've bought a new Macintosh, and now you may... Read More
Enabling Chinese input is quick and easy, there are only... Read More
(1) Avoid using the same variable again and again for... Read More
Microsoft Business Solutions ? Great Plains is designed to meet... Read More
Great Plains Inventory Management (IV) module gives your business a... Read More
Find out why Spyware Removal from computers is important and... Read More
Microsoft Business Solutions Navision is main ERP application for European,... Read More
Background: For many organizations like ours, the interim target of... Read More
Looks like Microsoft Great Plains becomes more and more popular,... Read More
Programming Help for BeginnersWe write programs to instruct computers. When... Read More
Microsoft CRM is CRM answer from Microsoft Business Solutions.The whole... Read More
Executive SummaryAn effective plan for entering, cleaning and updating the... Read More
Microsoft CRM is new player on the CRM software... Read More
We were recently faced with a decision: either to let... Read More
Lotus Notes Domino is very efficient in electronic document workflow... Read More
If there still are few unprotected computers left, I haven't... Read More
Microsoft CRM and IBM Lotus Notes Domino seem to be... Read More
Microsoft has never released a service pack for Windows98 SE,... Read More
Icons are used everywhere; right from software applications, to internet... Read More
When you own a small business, time is money. And... Read More
Bad News - the Threat is Bigger than it SeemedHow... Read More
Software |