C language provides several basic data types that are used to define variables. Here are some of the basic data types in C:
1. int: Integer data type is used to store whole numbers. It can be both positive and negative.
int
x = 10;
2. float: Float data type is used to store floating-point numbers (real numbers).
float
pi =
3.14;
3. double: Double data type is used to store double-precision floating-point numbers. It provides more precision than the float data type.
double
bigNumber
= 123456789.987654321;
4. char: Char data type is used to store a single character.
char
grade = 'A';
5. short: Short data type is used to store small integers.
short smallNumber = 5;
6. long: Long data type is used to store large integers.
long bigInteger = 1234567890;
7. long long: Long long data type is used to store very large integers.
long long veryBigInteger = 1234567890123456789LL;
8. _Bool: Bool data type is used to represent boolean values. It can have values either true (1) or false (0).
_Bool isTrue = 1;
9. void: Void is a special data type that indicates the absence of a specific type.
void myFunction() {
// some code
}- These data types can be used to declare variables, and the choice of a data type depends on the kind of data we want to store and the range of values it needs to cover. The size of these data types may vary depending on the compiler and the platform.
No comments:
Post a Comment