C++
Data types
In
C++, the data types are classified as three main categories
(1)
Fundamental data types
(2)
User-defined data types and
(3)
Derived data types.
In
this chapter, we are going to learn about only the Fundamental data types.
In
order to understand the working of data types, we need to know about variables.
The variables are the named memory locations to hold values of specific
data types. In C++, the variables should be declared explicitly with their data
types before they are actually used.
<data type> <variable
name>;
int num1;
To
declare more than one variable which are of the same data type using a single
statement, it can be declared by separating the variables using a comma.
int num1, num2, sum;
For
example, to store your computer science marks; first you should declare a
variable to hold your marks with a suitable data type. Choosing an appropriate
data type needs more knowledge and experience. Usually, marks are represented
as whole numbers. Thus, your variable for storing the computer science marks
should be an integer data type.
int comp_science_marks;
Now,
one variable named comp_science_marks
is ready to store your marks.
We
will learn more about variables later in this chapter.
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.