0% found this document useful (0 votes)
23 views3 pages

PDF 3

C++ has several built-in data types for storing integers, floating-point numbers, characters, and Boolean values. Floating-point numbers are interpreted as double by default, whole numbers as int by default. Numbers can be represented using decimal, binary, and hexadecimal systems. Arrays store a sequence of items accessed using an index.

Uploaded by

Yash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views3 pages

PDF 3

C++ has several built-in data types for storing integers, floating-point numbers, characters, and Boolean values. Floating-point numbers are interpreted as double by default, whole numbers as int by default. Numbers can be represented using decimal, binary, and hexadecimal systems. Arrays store a sequence of items accessed using an index.

Uploaded by

Yash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Fundamental Data Types 1

Data Types
Terms
Array Floating-point number
Binary system Hexadecimal system
Boolean values Index
Casting Over ow
Characters Run-time error
Compile-time error Stream manipulator
Data type String
Decimal system Under ow

Summary
• C++ has several built-in data types for storing integers (whole numbers), oating-point
numbers (numbers with a decimal point), characters, and Boolean values (true/false).

• Floating-point numbers are interpreted as double by default. To represent a oat, we


have to add the F suf x to our numbers (eg 1.2F).

• Whole numbers are interpreted as int by default. To represent a long, we have to use
the L suf x (eg 10L).

• Using the auto keyword, we can let the compiler infer the type of a variable based on its
initial value.

• Numbers can be represented using the decimal, binary, and hexadecimal systems.

• If we store a value larger or smaller than a data type’s limits, over owing or under owing
occurs.

Copyright 2022 Code with Mosh codewithmosh.com


fl
fl
fi
fi
fl
fl
fl
fl
Fundamental Data Types 2

• Using the sizeof() function, we can see the number of bytes taken by a data type.

• We can use stream manipulators to format data sent to a stream. The most common
manipulators are setw, xed, setprecision, boolalpha, left, and right.

• The Boolean false is represented as 0. Any non-zero number is interpreted as the


Boolean true.

• In C++, characters should be surrounded with single quotes.

• Characters are internally represented as numbers.

• A string is a sequence of characters and should be surrounded by double quotes.

• We use arrays to store a sequence of items (eg numbers, characters, etc).

• Array elements can be accessed using an index. The index of the rst element in an
array is 0.

• When we store a smaller value in a larger data type, the value gets automatically cast
(converted to) the larger type. When storing a large value in a smaller data type, we
have to explicit cast the value.

• C-style casting involves pre xing a variable with the target data type in parentheses. In
C++, we use the static_cast operator.

• C++ casting is safer because conversion problems can be caught at the compile-time.
With C-style casting, we won’t know about conversion issues until the run-time.

Copyright 2022 Code with Mosh codewithmosh.com


fi
fi
fi
Fundamental Data Types 3

Copyright 2022 Code with Mosh codewithmosh.com

You might also like