Data Types
Datatype defined as the what type of data store in program , like int char etc.
- char --- it store single charecter data
- int --- it store interger values
- float --- it store floating values
- double --- it store floating values ,but which have more precision than float
- Bool --- it storeboolean values, which can be either 0 (false) or 1 (true).
Types of basic Datatype
Data Type | Format Specifier | Description |
---|---|---|
int | %d | integer in decimal. |
float | %f | Float. |
char | %c | Character. |
string | %s | String. |
Boolean (Using integers) | %d | Use with integers (0 for false, 1 for true) to print boolean values. |
Example
#include <stdio.h> // importing booling in header #include <stdbool.h> main() { /* initializing & declaring data types with values.*/ int age = 42; float percentage = 3.14; double bigper= 123.456789; char grade = 'A'; bool boolVar = true; // 1 represents true printf("Age in integer: %d\n", age); printf("Percentage in float: %.2f\n", percentage); printf("Bigpercentage in double: %lf\n", bigper); printf("Grade incharacter: %c\n", grade); printf("Boolean value in bool : %d\n", boolVar); }