Data Types in C Programming Language in Sinhala- Lesson 06
C programming language එකේදී අපි data types යොදාගනු ලබන්නේ variables එකක් declare කරගැනීමට හෝ විවිද වර්ගයේ functions සාදා ගැනීමට. Data type එකෙන් තීරණය කරන්නේ එම declare කරන ලද variable එකට RAM එකේ කොපමණ ඉඩ ප්රමාණයක් වෙන්කරගතයුතුද යන්නයි. (ඊලග Lesson එකෙන් variables declare කරන ආකාරය සහ memory layout එක ගැන කියල දෙන්නම්.)
C Data Types මේ ආකාරයට classify කරන්න පුළුවන්.
1.) Basic Types
මේවා arithmetic types (අංක ගණිතමය) variables. මේවා types 2ක් තියෙනවා.
- integer types
- Floating-point types
2.) Enumerated types
මේවත් arithmetic types (අංක ගණිතමය) variables. මේවා programmer විසින් define කරගන්න data types. මේ type එක ප්රදාන වශයෙන් use කරන්නේ නිඛිලමය නියතයන්ට names assign කරගන්න.
3.) The type void
Void data type එක මගින් indicate කරන්නේ variable එකට value එකක් නැති බව.
4.) Derived types:
- Pointer types
- Array types
- Structure types
- Union types
- Function types
Array types සහ structure types එකතුවක් (data set) නිරුපණය කරනවා. (aggregate types)
Function type එකෙන් නිරුපනය කරන්නේ function එකේ return value එක.
Integer Types
Integer Types වලින් declare කරන ලද variables වල store කරන්න පුළුවන් data size එක සහ අගයන් පරාසය.
Floating-Point Types
Floating-Point Types වලින් declare කරන ලද variables වල store කරන්න පුළුවන් data size එක සහ අගයන් පරාසය.
The void Type
කලින් කිව්වා වගේ Void data type එක මගින් දක්වන්නේ variable එකට value එකක් නැති බව. C programming වලදී අවස්ථා 3 කදී අපි void use කරනවා.
1.) Function returns as void
Function එකකින් කිසිම value එකක් return වෙන්නේ නැත්නම් return type එක විදියට void use කරන්න පුළුවන්.
Example: void exit (int status);
2.) Function arguments as void
සමහර Functions තියෙනවා function එක run වෙලා ඉවර උනාම parameter එකක් pass වෙන්නේ නැති functions. මෙන්න මේවට parameter type එක විදියට void දෙන්න පුළුවන්.
Example: int rand(void);
3.) Pointers to void
Pointer of type void මගින් object එකකට address එකක් නිරුපනය කරනවා.
Example: a memory allocation function
void *malloc( size_t size );
(මේවා තව explain කරන්නම් ඉස්සරහ lessons වලදී මේවා use වෙනකොට.)