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

3-Intro-CPP-Data Types-int-float-char-array-ASGMNT-3-03-FEB-2021

This document discusses C++ data types. It describes three main categories of data types in C++ - primitive, derived, and abstract or user-defined. Primitive data types are built-in types like int, char, float, and bool. Derived types are those derived from primitive types, like arrays, pointers, and references. Abstract types are custom types defined by the user, such as classes, structures, unions, and enumerations. The document then provides details on C++'s primitive data types, including their keywords, memory usage, and value ranges. It also includes an ASCII table describing the first 32 non-printing characters.

Uploaded by

daytdeen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views

3-Intro-CPP-Data Types-int-float-char-array-ASGMNT-3-03-FEB-2021

This document discusses C++ data types. It describes three main categories of data types in C++ - primitive, derived, and abstract or user-defined. Primitive data types are built-in types like int, char, float, and bool. Derived types are those derived from primitive types, like arrays, pointers, and references. Abstract types are custom types defined by the user, such as classes, structures, unions, and enumerations. The document then provides details on C++'s primitive data types, including their keywords, memory usage, and value ranges. It also includes an ASCII table describing the first 32 non-printing characters.

Uploaded by

daytdeen
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

INTRODUCTION: C++ DATA TYPES

 All variables use data-type during declaration to restrict the type of


data to be stored.
 Therefore, we can say that data types are used to tell the variables
the type of data it can store.
 Whenever a variable is defined in C++, the compiler allocates some
memory for that variable based on the data-type with which it is
declared.
 Every data type requires a different amount of memory.

Primitive Data Types: These data types are built-in or predefined data
types and can be used directly by the user to declare variables. example:
int, char, float, bool etc. Primitive data types available in C++ are:
 Integer
 Character
 Boolean
 Floating Point
 Double Floating Point
 Valueless or Void
 Wide Character

Derived Data Types: The data-types that are derived from the primitive
or built-in datatypes are referred to as Derived Data Types. These can
be of four types namely:
 Function
 Array
 Pointer
 Reference
Abstract or User-Defined Data Types: These data types are defined
by user itself. Like, defining a class in C++ or a structure. C++ provides
the following user-defined datatypes:
 Class
 Structure
 Union
 Enumeration
 Typedef defined DataType

This article discusses primitive data types available in C++.

 Integer: Keyword used for integer data types is int. Integers


typically requires 4 bytes of memory space and ranges from -
- 2147483648 to 2147483647.

 Character: Character data type is used for storing characters.


Keyword used for character data type is char. Characters
typically requires 1 byte of memory space and ranges from -128
to 127 or 0 to 255.

 Boolean: Boolean data type is used for storing boolean or


logical values. A boolean variable can store either true or false.
Keyword used for boolean data type is bool.

 Floating Point: Floating Point data type is used for storing


single precision floating point values or decimal values.
Keyword used for floating point data type is float. Float
variables typically requires 4 byte of memory space.
 Double Floating Point: Double Floating Point data type is used
for storing double precision floating point values or decimal
values. Keyword used for double floating point data type
is double. Double variables typically requires 8 byte of memory
space.

 void: Void means without any value. void datatype represents a


valueless entity. Void data type is used for those function which
does not returns a value.

 Wide Character: Wide character data type is also a character


data type but this data type has size greater than the normal 8-
bit datatype. Represented by wchar_t. It is generally 2 or 4
bytes long.

ASCII Table: ASCII Table and Description

 ASCII stands for American Standard Code for Information


Interchange.
 Computers can only understand numbers, so an ASCII code is the
numerical representation of a character such as 'a' or '@' or an
action of some sort.
 ASCII was developed a long time ago and now the non-printing
characters are rarely used for their original purpose.
 Below is the ASCII character table and this includes descriptions of
the first 32 non-printing characters.
 ASCII was actually designed for use with teletypes and so the
descriptions are somewhat obscure.
Practice:
ACTIVITIES:

1) Write a C++ program to read ‘n’ integers from user and store them in

an integer array (say arr_numbers[]) . Read the value of ‘n’ from

user using cin>>. Find the sum of all numbers of the arr_numbers[].

Print the array elements and their sum on the screen.

2) Write a C++ program to find the number of vowels in a character

array. Print the results clearly.

3) Explore array data type in C++.

4) List out the advantages and disadvantages of array data type in C++.

5) What is a variable in C++? What are the rules to be followed while

clearing variables?

6) Explore different keywords supported in C++ language.

You might also like