Day 2 C++ File 2
Day 2 C++ File 2
Day-2
- Why OOPs concept?
1.Increase readability
2.less complex
3.easy to modify
• Data type :- It specifies the type of data that the variable can store like integer, character, floating,
double, etc. Each data type requires different amounts of memory and has some specific operations
which can be performed over it.
• Variable :- Variables in C++ is a name given to a memory location. It is the basic unit of storage in a
program. The value stored in a variable can be changed during program execution. Which can store the
literals .
• Literals:- A constant is known as literals. A constant value which are assigning to variable is known as
literals
Data Types
Short
int
Derive datatype
Long
Float
ARRAY
Double Structure
Boolean class
Char
o Primitive Data type :- Primitive is the most fundamental data type usable in the Programming language. There
are eight primitive data types: Boolean, byte, character, short, int, long, float, and double. In a Programming
language, these data types serve as the foundation for data manipulation. All basic data types are built-in into
the majority of programming languages.
o Derive Data type :- The data type which can be derived from the fundamental datatype . i,e as the collection of
integer is called as array & the collection of char is called as String.
o Non – Primitive data type :- These are user-defined data types created by programmers. These data types are
used to store multiple values. Non-primitive types can be used to call methods to perform certain operations,
while primitive types cannot. Non-primitive data types are called reference types because they refer to objects.
Fundamental Data type
eg. 0 or 1
Char , boolean
OUTPUT IS →
Note:- As we know ,
1 byte = 8 bit
0 → 1bit →
Therefore ,
Short -→ 2 byte → 16 bit
| | | | | | |
16 box
-4 3
= -2n-1 = 2n-1 -1
Note:- The value of signed will be in +ve as well as in -ve side I,e.
from -2n-1 to 2n-1 -1 .
But in case of unsigned it starts from zero and end at 2n-1 -1.
➢ If we write the value of int x=65536 the it is invalid because we
know that the range of int is upto 65535 so, it will come in
long data type.