1 of 19

WELCOME�TO�SEMINAR

ON TOPIC: BASIC DATATYPES(Built in types)

BY: Saakshi J.Shetty(20422)

2 of 19

There are 3 types of Data types in C++…

3 of 19

C++ datatypes

  • Built in Datatypes.
  • User defined datatypes
  • Derived datatypes

4 of 19

Definition of built in types

  • The term Built-in itself tells us that these categories of data types are defined by the programming language at prior.
  • Built-in Data types are those data types that can be directly used by the programmer to declare and store different variables in a program.
  • They are also called Primary or Primitive Data Types.

5 of 19

Classifications

Built-in-datatypes are of 3 types:

  • Integral type
  • Void
  • Floating type

​

Int

Char

Float

Double

6 of 19

Description on built-in- datatypes

  • Built-in data types are the most basic data-types in C++.
  • The term built-in means that they are pre-defined in C++ and can be used directly in a program.
  • char, int, float and double are the most common built-in data types.
  • Apart from these, we also have void ,bool and wchar_t data types.

7 of 19

Int, char, float, double, boolean, void ,wide character - are the most basic and common built-in data types in every programming language. Other than these if you want to work with complex data categories, you will have to define them yourself.

8 of 19

Types and examples of built in datatypes.(integer datatype-int)

  • This Built-in data type represents an integer number. It does not support any decimal or fractional number. Integer numbers can contain Positive as well as Negative numbers.
  • Ex:- 29, -50, 1947, 50384
  • Syntax: int variable_name;
  • Example: int a;

​

9 of 19

Character datatype-char

  • This data type accepts character values from the user. These characters include single letter, digit, symbol, special characters, etc enclosed within single quotes. Ex:- ‘A’, ‘$’, ‘g’, ‘5’
  • Syntax: char variable_name;
  • Example:char a;

​

​

​

​

10 of 19

Float datatype-float

  • Float data type represents numbers that are in decimal format. They are commonly called floating-point numbers. Ex:- 25.56, 785.383, -3674.7358, -10
  • Syntax: float variable_name;
  • Example: float a;

11 of 19

Double datatype- double

  • It is a variant of the Floating-point data type which is also used to represent fractional and decimal numbers. Ex:- 260000.7334
  • Syntax:- double variable_name;
  • Example: double a;

​

​

12 of 19

Boolean Datatype-bool

  • This data type consists of only 2 values: True or False. It is a logical type of built-in data type. The default value of Boolean data type is False.
  • Ex:- True,false,0,1,2,3
  • Syntax: bool variable_name;
  • Ex:- bool x = 0;  // false

bool y = 100;  // true

​

13 of 19

Void datatype: void

  • This data type is widely used in C and C++ languages. It indicates that it has no value/empty. This data type is mainly used as a return type for functions that do not return a value to the caller function.
  • Syntax:- void function_name(void)
  • Example:- void print()

14 of 19

Wide character datatype: wchar_t

  • Wide char is similar to char data type, except that wide char take up twice the space and can take on much larger values as a result.
  • char can take 256 values which corresponds to entries in the ASCII table. On the other hand, wide char can take on 65536 values which corresponds to UNICODE values.
  • Just like the keyword for character constants is char, the keyword for wide character is wchar_t.
  • Syntax: wchar_t variable_name;
  • Example: wchar_t w ;

​

​

15 of 19

The discussed datatypes can be classified further into following types:

  • Long
  • Short
  • Signed
  • Unsigned

For example:

  1. short int
  2. long int
  3. signed int
  4. unsigned int
  5. signed char
  6. unsigned char
  7. unsigned short int
  8. signed short int

​

​

16 of 19

Sizes of each datatype:

Sno

Datatypes

Sizes(in bytes)

1

void

0

2

char

1

3

bool

1

4

int

2

5

wchar_t

2

6

float

4

7

double

8

17 of 19

Ranges of each datatype:

18 of 19

IT’S TIME FOR PROGRAMMING EXAMPLE…..

19 of 19