0% found this document useful (0 votes)
24 views

C++ Start

The document discusses user interaction in programs by accepting input through the cin function followed by the insertion operator (>>). It explains that input must be stored in variables, which are declared with a data type (such as char, int, or float) to store different kinds of information like characters, integers, or decimal numbers respectively. Variables allow programs to save input or other data for use within the program.

Uploaded by

Zeshan Ahmed
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

C++ Start

The document discusses user interaction in programs by accepting input through the cin function followed by the insertion operator (>>). It explains that input must be stored in variables, which are declared with a data type (such as char, int, or float) to store different kinds of information like characters, integers, or decimal numbers respectively. Variables allow programs to save input or other data for use within the program.

Uploaded by

Zeshan Ahmed
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

User interaction and Saving Information with

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. 

A variable of type char stores a single character,


variables of type int store integers (numbers without
decimal places), and variables of type float store
numbers with decimal places. Each of these variable
types - char, int, and float - is each a keyword that you
use when you declare a variable.

You might also like