Skip to main content

Summary

Below are some tables with summary of data types and format codes. There are more to it than this but for now these are the ones that you will need to worry about.

DescriptionData TypeFormat CodesSizeRange (inclusive)
floating pointfloat%f32 bits - 4 bytesN/A
more accurate floating pointdouble%lf64 bits - 8 bytesN/A
characterschar%c8 bits - 1 byte-128 to 127, values are often used to encode various characters
whole numbersint%d32 bits - 4 bytes-2147483648 to 2147483647
small whole numbersshort or short int%hd16 bits - 2 bytes- 32768 to 32767
big whole numberlong or long int%ld32 bits - 4 bytes or 64 bits - 8 bytes-2147483648 to 2147483647 or 263-2^{63} to 26312^{63} - 1
much bigger whole numberlong long or long long int%lld64 bits - 8 bytes263-2^{63} to 26312^{63} - 1
warning

Size/Range information is based on typical current computers. It is not fixed. In older computers for example integers were only 16 bits. If the size changes the range changes.

Outside of the above, the following modifiers can be applied:

unsigned:

  • can be applied to integer types (long, int, char, short)
  • all bits of the value are used to represent a number without the use of a sign bit
  • unsigned int range from 0 to 4294967295 inclusive
  • unsigned char range from 0 to 255 inclusive

Check it out for yourself!

Try this program on your computer to see how big the various types are!

#include <stdio.h>
int main(void){

printf("size (number of bytes) of a char: %lu\n", sizeof(char));
printf("size (number of bytes) of a int: %lu\n", sizeof(int));
printf("size (number of bytes) of a float: %lu\n", sizeof(float));
printf("size (number of bytes) of a double: %lu\n", sizeof(double));
printf("size (number of bytes) of a long: %lu\n", sizeof(long));
printf("size (number of bytes) of a short: %lu\n", sizeof(short));
printf("size (number of bytes) of a long long: %lu\n", sizeof(long long));
return 0;
}

Special Characters

Character you wantWhat to Type
newline\n
tab\t
backslash ( \ )\\
percent sign (%)%%
doublequote (")\"
beep (audible beep sound)\a