Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
#include <stdio.h> #include <stdint.h> /* fixed-width types */ int main(void) { /* Basic types */ char c = 'A'; short s = 32000; int i = -42; long l = 1000000L; float f = 3.14f; double d = 2.718281828; /* Fixed-width types from <stdint.h> */ uint8_t byte = 255; int32_t word = -100000; uint64_t big = 18446744073709551615ULL; /* sizeof returns the size in bytes */ printf("char: %zu bytes ", sizeof(char)); printf("short: %zu bytes ", sizeof(short)); printf("int: %zu bytes ", sizeof(int)); printf("long: %zu bytes ", sizeof(long)); printf("float: %zu bytes ", sizeof(float)); printf("double: %zu bytes ", sizeof(double)); printf("int32_t: %zu bytes ", sizeof(int32_t)); printf("c=%c s=%d i=%d l=%ld ", c, s, i, l); printf("f=%.2f d=%.9f ", f, d); printf("byte=%u word=%d ", byte, word); return 0; }
Result
Open