c data types
Type Size (bytes) Format Specifier
int at least 2, usually 4 %d, %i
char 1 %c
float 4 %f
double 8 %lf
short int 2 usually %hd
unsigned int at least 2, usually 4 %u
long int at least 4, usually 8 %ld, %li
long long int at least 8 %lld, %lli
unsigned long int at least 4 %lu
unsigned long long int at least 8 %llu
signed char 1 %c
unsigned char 1 %c
long double at least 10, usually 12 or 16 %Lf
3.8
10
char 1 byte -128 to 127 or 0 to 255
unsigned char 1 byte 0 to 255
signed char 1 byte -128 to 127
int 2 or 4 bytes -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647
unsigned int 2 or 4 bytes 0 to 65,535 or 0 to 4,294,967,295
short 2 bytes -32,768 to 32,767
unsigned short 2 bytes 0 to 65,535
long 8 bytes or (4bytes for 32 bit OS) -9223372036854775808 to 9223372036854775807
unsigned long 8 bytes 0 to 18446744073709551615
Thank you!
10
0
3.86
7
C datatypes and bytes
Thank you!
7
0
3.8
5
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#define FailedToEducate 101
#define Success 400
int main(void) {
/*
A long int is:
32-bit compiler:
MIN: -2,147,483,648
MAX: 2,147,483,647
unsigned MAX: 4,294,967,295
64-bit compiler:
MIN: -9,223,372,036,854,775,808
MAX: 9,223,372,036,854,775,807
unsigned MAX: 18,446,744,073,709,551,615
Therefore...a long int will either be
-2,147,483,648 and 2,147,483,647 for a 32-bit compiler
or -9,223,372,036,854,775,808 and
9,223,372,036,854,775,807 for a 64-bit compiler,
whilst a long long int will just be
-9,223,372,036,854,775,808 and
9,223,372,036,854,775,807
I hope this made sense!
*/
bool userUnderstands=true;
if(userUnderstands) {
exit(Success);
} else {
exit(FailedToEducate);
}
}
Thank you!
5
0
Are there any code examples left?
New code examples in category C
-
C 2022-03-27 22:30:45 Problem Statement Print the following output: \ Input Format IN Output Format \
-
C 2022-03-27 18:30:08 how to free memory in c
-
C 2022-03-27 18:00:14 linux command line windows
-
C 2022-03-27 18:00:02 C example of if else
-
C 2022-03-27 17:10:18 sum of digits in c using for loop
-
C 2022-03-27 12:35:50 replace word in c
-
C 2022-03-27 07:40:11 How to setup a line length marker in vim
-
C 2022-03-27 07:35:09 Multi Select with icons htm;