ডেটা টাইপ হল মেমরি লোকেশন বা ভেরিয়েবলের ডিক্লেয়ারেশন যা ডেটার ধরন নির্দেশ করে। সি-তে বিল্ট-ইন ডেটা টাইপগুলোর সাইজ মেশিন আর্কিটেকচারের ওপর নির্ভর করে।
বিল্ট-ইন ডেটা টাইপ
int,float,charunsigned int,unsigned charlong int,double,long double,void
ব্যবহার উদাহরণ
char grade = 'A';
int count = 10, index = 10;
float average = 6.9;
সাইজ চেক করার প্রোগ্রাম
#include <stdio.h>
int main() {
int x = 10;
char c;
printf("Size of variable x = %ld bytes\n", sizeof(x));
printf("Size of variable c = %ld byte\n", sizeof(c));
printf("Size of short = %ld bytes\n", sizeof(short));
printf("Size of int = %ld bytes\n", sizeof(int));
printf("Size of long = %ld bytes\n", sizeof(long));
printf("Size of float = %ld bytes\n", sizeof(float));
printf("Size of double = %ld bytes\n", sizeof(double));
printf("Size of long double = %ld bytes\n", sizeof(long double));
printf("Size of char = %ld bytes\n", sizeof(char));
printf("Size of void = %ld bytes\n", sizeof(void));
return 0;
}
সামান্য আউটপুট (৩২-বিট সিস্টেমে)
Size of variable x = 4 bytes Size of variable c = 1 byte Size of short = 2 bytes Size of int = 4 bytes Size of long = 4 bytes Size of float = 4 bytes Size of double = 8 bytes Size of long double = 16 bytes Size of char = 1 byte Size of void = 1 byte