C++ Tutorial 2, Input and Variables

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

In The News:


pen paper and inkwell


cat break through


Beware of Spyware

One day, you suddenly realize that your computer started to... Read More

Beware of The Pirated Software E-Mail Scams!

You have gotten those E_Mails buy software at deep discounts.... Read More

eConnect: eCommerce Development for Microsoft Great Plains

Microsoft Business Solutions Great Plains has several options to enable... Read More

What You Must Know About Spyware Right Now

Spyware is like the new technological nuclear weapon on the... Read More

How a Bug Challenges to a Software Professional

It is really interesting that a bug can create problem... Read More

Microsoft Navision and Crystal Reports - An Overview

Microsoft Business Solutions ? Navision is an integrated solution for... Read More

Microsoft CRM Integration with IBM Lotus Notes Domino ? Machinery Dealership Example

IBM Lotus Notes with Domino email server is traditional document... Read More

Microsoft Great Plains Subcontracting ? Overview for Microsoft Business Solutions Partner

Microsoft Business Solutions Great Plains is very popular ERP/MRP applications... Read More

The Truth about Colossus: Are You Just A Magnetic Image?

What is Colossus?Colossus is software licensed to about twenty-five insurance... Read More

Tools for Customizing Great Plains

Microsoft Business Solutions ? Great Plains has captured the US... Read More

Corel WordPerfect 7 Macro Programming Example

Case study: A secretary using Corel WordPerfect 7 is often... Read More

Great Plains Customization Upgrade? Overview For CIO/IT Director

Around the same time Microsoft made its move with .Net... Read More

Software Automation Helps Increase your Bottom Line

When you own a small business, time is money. And... Read More

What is Fleet Maintenance Management?

Fleet Maintenance Management is a critical position in any company... Read More

Microsoft Great Plains: Service Business Customization & Integration Example

Microsoft Business Solutions Great Plains might be considered as ERP... Read More

The Software 2005 Conference - A Review

The Software 2005 conference is now a wrap. This conference,... Read More

Microsoft Business Solutions - Navision Customization: C/SIDE, C/ODBC, C/FRONT, XBRL

Microsoft bought Navision, Denmark based software development company, along with... Read More

Secure File Transfer Using SSH Plus Additional Audit & Automation - FSA Reporting

In order to meet regulatory and corporate compliance requirements reporting... Read More

Microsoft Great Plains on Ctree or Pervasive SQL ? What to Do ? Tips for IT Manager

As you probably know, when Microsoft purchased Great Plains Software... Read More

Microsoft CRM Customization: Integration with Third Party SQL Application/Database

Microsoft CRM ? Client Relationship Management package from Microsoft Business... Read More

Mozilla Vs. Firefox

For those who are unclear on the differences between the... Read More

Microsoft Great Plains PM: Payables Management

Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More

Microsoft Great Plains Integration Manager: Using Continuum ? Overview for Developer

Microsoft Business Solutions Great Plains has I'd say end user... Read More

Microsoft Great Plains BR: Bank Reconciliation

Microsoft Business Solutions Great Plains is marketed for mid-size companies... Read More

What is Preventive Maintenance Software?

Preventive Maintenance (PM) is defined as scheduled work done on... Read More

Great Plains Sales Order Processing and Invoicing Modules ? Tips For Consultants

We'll give you non formal view, based on our consulting... Read More

How To Develop Software For Your Business

Software development is a risky business.Many software developers are barely... Read More

Demand More From Your Lead Tracking Software

An integral part of any quality CRM system is lead... Read More

Hubris - Definition: Microsofts Passport

Before September of 1995, Microsoft ignored the Internet because their... Read More

Great Plains Customization ? Programming Auto-apply in Accounts Receivable

Microsoft Great Plains is one of three Microsoft Business Solutions... Read More

Computer Based Language Development and Spell-checking

Language development computer: Computer-based method for aiding language development seems... Read More

What is Shareware?

Shareware is software that you can try before you buy;... Read More

A Time-Saving Programming Tactic that Doesn?t Work

Let's say that you have a software project that's under... Read More