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
last minute cleaning help Arlington Heights ..Anti-virus software is used to find, remove or fix files... Read More
If you have Microsoft Great Plains and support it for... Read More
In the early days of the personal computer, we're talking... Read More
Have you noticed WordPerfect is gearing up for a comeback... Read More
Microsoft Business Solutions Great Plains is Dexterity-written application and currently... Read More
I've been active in the Cisco Certification track for four... Read More
It is possible that if one avoided all sources of... Read More
If you company is small or mid-size special products or... Read More
IntroductionSurprised, by the title? well, this is a tour of... Read More
In a previous article, I wrote about OpenOffice... Read More
The COSMIC FP (function point) software quality metric, is no... Read More
It is really interesting that a bug can create problem... Read More
With any good luck and a good amount of hard... Read More
If you copy something from a Web site or elsewhere...... Read More
Document Manager and Version HistoryIn previous articles I have discussed... Read More
Microsoft SQL Server is the leader for inexpensive and middle... Read More
When Great Plains Software was designing and developing Great Plains... Read More
We will base our prognosis on our Microsoft Business Solutions... Read More
Microsoft Business Solutions Small Business Manager is scaled down Great... Read More
Looks like Microsoft Great Plains becomes more and more popular,... Read More
For those who still don't know, Microsoft Publisher helps computer... Read More
Microsoft Business Solutions Great Plains has several options to enable... Read More
We would like to give you several situations, when you... Read More
Since technology changes so quickly, it is hard to begin... Read More
I have always regretted how Microsoft price gouges and rips... Read More
same day cleaning service Wilmette ..The vast majority of us will have, at some point,... Read More
MSN messenger is a pretty cool invention. I mean I'm... Read More
A UNIX Shell is in simplest terms, a command line... Read More
Spyware and malware are large problems for Internet users today... Read More
So, you've bought a new Macintosh, and now you may... Read More
Microsoft Business Solutions Great Plains, Navision, Axapta, Solomon and CRM... Read More
... Read More
Most people don't use Photoshop to its fullest capabilities. Here... Read More
The intuitive algorithm.Roger Penrose considered it impossible. Thinking could never... Read More
Navision Software was purchased by Microsoft and now it is... Read More
If you have Microsoft Great Plains and support it... Read More
In part III of this ISDN primer, we learned that... Read More
Just stress testing one of the latest Linux distributions. Been... Read More
Looking at all the ads which promise to get rid... Read More
Now there are Three Steps To Heaven Just listen and... Read More
Microsoft CRM and IBM Lotus Notes Domino seem to be... Read More
If you have Microsoft Great Plains and support it for... Read More
Stop the Runaway MouseWhat's the "runaway mouse?" You've seen it...you... Read More
If someone entered your home, uninvited and installed numerous cameras... Read More
It's all about turn times in the eMedia industry! The... Read More
In order to implement VLANs in a network environment, you'll... Read More
MS CRM is very close to document workflow automation, including... Read More
Task Manager is a Windows system utility that displays thetasks... Read More
With so many Microsoft Windows related viruses, errors, and other... Read More
IntroductionDuring the early years of our modern computer era, very... Read More
Software |