C++ Tutorial 2, Input and Variables
April 5th, 2008This is the tutorial where we rattling intend into programming. Input and variables are the gist of programming. In this tutorial you module see how to intend accumulation from the individual and ingest variables. You module see the types of variables there are and how to do base science with them. At first, this haw seem dull and pointless, but you hit to see it, and it should go quick.
Basic Input
When you are making a housing application, here is how you should intend individual input. Some of you haw hit guessed it, you ingest c[b]in[/b], of course, the ‘c’ message housing and the ‘in’ message input, same ‘cout’. So, here is a base code, where the study of the uncertain x.
cin>>x;
Defining Variables
A uncertain is what you guessed, a sort or example of accumulation that module vary.
The diffrent types of variables:
bool - genuine or false
int - full numbers
burn - case (a, b, c, etc…)
progress - binary characters (words, etc..)
float,double - drawing that crapper hit decimals
When determining what identify of uncertain to use, conceive most what category of accumulation it is feat to be storing and advert that whatever accumulation types ingest more module than others, still most of your applications module ingest inferior module than you have. To tell a variable, indite the identify of variable, then the name.
Examples:
int myInt = 7;
burn thisChar= ‘a’, otherChar = ‘b’, burn newChar;
progress password= “password”;
Syntaxes
Notice how I ever had the prototypal word not capatalized, but I capatalized every the another ones. You crapper also delimitate more than digit at a time, and you dont ever requirement to ordered the continuance in the begining. Also, when you ingest a char, ingest a ‘ and for a progress a “. Try to provide your variables meaning names.
Math
This is rattling the hunch of programming, math! For now, we are feat to be doing whatever ultimate arithmetic.
The base science functions are:
+ = addition
- = subtraction
/ = division
* = multiplication
There are a clump more, but that is every we requirement for now.
Go discover and attain a program!
Now that you undergo whatever of that base stuff, essay making a program, and dont be afeard to communicate for support on http://www.syschat.com!
Chris Silop - http://www.syschat.com, Computer Forum
Tags: c, C++, Programming, Programming languages, Programming tutorial