sizeof
Completed
Print the size in bytes of char, int and double, one per line, as type: N.
Input
None.
Output
Three lines.
Example
Output
char: 1 int: 4 double: 8
Editor
C
Hints
sizeof gives the size of a type in bytes.
Cast it to int to print with %d.
Solution explanation
Sizes depend on the platform; sizeof tells you the truth for the machine running the code.
Show solution
#include <stdio.h>
int main() {
printf("char: %d\n", (int) sizeof(char));
printf("int: %d\n", (int) sizeof(int));
printf("double: %d\n", (int) sizeof(double));
return 0;
}