C++ Start
C++ Start
Variables
So far you've learned how to write a simple program to display
information typed in by you, the programmer, and how to describe
your program with comments. That's great, but what about interacting
with your user? Fortunately, it is also possible for your program to
accept input. The function you use is known as cin, and is followed by
the insertion operator >>.
Of course, before you try to receive input, you must have a place to
store that input. In programming, input and data are stored in
variables. There are several different types of variables which store
different kinds of information (e.g. numbers versus letters); when you
tell the compiler you are declaring a variable, you must include the
data type along with the name of the variable. Several basic types
include char, int, and float.