DATA TYPES IN C++…
DATA TYPES IN C++
Data Type என்பது ஒரு variable எந்த வகையான data-ஐ store செய்ய வேண்டும் என்பதை compiler-க்கு தெரிவிக்கும் type. Simple definition: A data type specifies what kind of value a variable can store.
Data Type என்பது ஒரு variable எந்த வகையான data-ஐ store செய்ய வேண்டும் என்பத……
int age = 25; இங்கு: int → Data type age → Variable / Identifier ……
Real life-ல் different containers different things-க்கு use செய்வோம். Water bottle → Water Rice bag → Rice Mo……
Consider: int marks = 90; Compiler தெரிந்து கொள்கிறது: marks → Integer value Another example: char grade = 'A……
C++ data types broadly: Data Types │ ├── 1. Fundamenta……
FUNDAMENTAL / BASIC DATA TYPES
Main basic data types: int char float……
int integer numbers store செய்ய பயன்படும். Int……
int variable_name; int age = ……
return 0; }…
int normally whole number. Correct: int marks = 90; But: int value = 10.75; இங்கு dec……
float decimal / fractional nu……
float price = 25.50f; Other example……
return 0; }…
float single-precision floating-p……
float x = 3.141592f;…
double decimal values-ஐ float……
double pi = 3.141592653589793;…
float a = 3.14f; double b = 3.141592653589793; Simple difference: float → Le……
return 0; }…
Default cout formatting may n……
char ஒரு single character sto……
char grade = 'A'; Character single quotes-ல் எழுத வேண்டும். Corre……
char grade = 'A'; char symbol……
char digit = '5'; இதில் '5' n……
return 0; }…
char usually occupies: 1 byte C++ standard guarantees: sizeo……
bool logical values store செய……
bool passed = true;…
return 0; } Usually output: 1……
If we want words: #include using ……
void means: No value / no type o……
display() function எந்த value……
#include using namespace std;……
This is invalid as a normal object declarat……
C++ integer types-க்கு modifiers use ……
int normally signed by default. signed int x = ……
unsigned negative values represent செய்ய பயன்படாது. u……
signed int a = -10; unsigned ……
Small integer type. short int……
Larger or at least not smaller than int in ran……
For still wider integer range……
C++ guarantees at least: short ≤ int ≤ long ≤ long long in ter……
On many modern systems, commo……
Except for char being exactly 1 byte by definition, ex……
To find actual size: #include……
This can vary by system.…
Every data type has a range. For a common 32-bit int: -2,147,483,648 to 2,147,483,647 Typical unsign……
C++ floating-point types: flo……
Higher or at least no less precision/range than double, depending……
Useful exam point: 10 → int literal 10L……
3.14 → double literal
3.14f → float literal 3.14L →……
string is commonly used in C++: string name = "Ravi"; But important tec……
return 0; }…
int → Integer float → Decimal double → Higher pr……
DERIVED DATA TYPES
Derived data types basic types-லிருந்து உ……
Same type values-ஐ collection ஆக store செய்கிறது. int marks[……
Another object-ன் memory address-ஐ store செய்கிறது. int ……
Existing variable-க்கு another name / alias. int x = 10; int &ref = x;……
USER-DEFINED DATA TYPES
Programmer உருவாக்கும் types. M……
Student programmer-created type. struct ……
Same memory area-ஐ multiple members sha……
At a given time, the active m……
Named integral constants define செய்ய பயன……
We can give another name to a type. Using typedef: ty……
return 0; }…
int age = 25; int → whole number. float height = 5.8f; float → decimal value. double salary = 35000.75; doubl……
ஒரு data type-லிருந்து another type-……
This is implicit conversion.…
Compiler automatically convert செய்க……
Programmer manually convert செய்கிறார். Modern C++: ……
double x = 9.99; int y = x;…
Not: 10 Integer conversion di……
Modern C++ supports: auto x = 10; Compiler infers: x → int ……
auto does not mean variable has no data typ……
const int MAX = 100; Here: const → ……
signed int a = -100; unsigned……
signed → Negative + Positive unsi……
int marks = 90; int → Data type marks → Variable / identifier 90 → Value Do not confuse. [DATA TYPE……
Character quotation Wrong: ch……
Decimal into int int x = 10.9; x……
Using text with char Wrong: char name = 'Ravi'……
Boolean confusion Correct: bool status = true; Not:……
Consider: int age = 20; double percentage = 89.75; char grade = 'A'; bool pass = true; Comp……
[INT vs FLOAT] int a = 10; St……
int → Integer float → Decimal double → More preci……
I F D C B V I → int F → float D → double C → char B → ……
What is a data type? A data type specifies the type of data……
1. Fundamental 2. Derived 3. ……
Examples: Fundamental → int, char, float, double, bool ……
Is string a primitive/fundamental C++ data type? No. std::s……
Is int always 4 bytes? No. int size is implementation-dependent. Many m……
Difference between float and double? double normally ……
Which data type stores intege……
Which is used for a single ch……
Which is a valid Boolean valu……
Which normally provides more ……
Which type indicates no retur……
Which is correct?…
Which is a derived data type?…
Which is a user-defined type?…
Which statement is technicall……
Which operator tells the stor……
Identify the data type: int age = 25; float weight = 65.5f; double pi = 3.141……
Choose suitable type: Student age → int Student grade → c……
C++ Data Type A data type tells the compiler what kind of value a variable can store. Main basic types: int →……