This program demonstrates the use of basic C data types to store and display values. C supports integer and real data types such as int and float. The char type is used to store character values and is treated as an integral type.
main.c
Copy to clipboard
#include <stdio.h>
int main()
{
int account_number;
float amount;
char currency;
account_number = 1024;
amount = 100.5;
currency = '$';
printf("Mr. Cat with account number %d owes me %f %c\n", account_number, amount, currency);
return 0;
}
Output:
Mr. Cat with account number 1024 owes me 100.500000 $
int is used to store whole numbers.float is used to store decimal values (single precision).char stores a single character and is internally represented as an integer value.
printf() uses format specifiers to print values:
%d→ integer%f→ float%c→ character