C
Loading...
Loading...
codewithc.in
| Type | Size | Range | Format |
|---|---|---|---|
| char | 1 byte | -128 to 127 | %c |
| unsigned char | 1 byte | 0 to 255 | %c |
| short | 2 bytes | -32,768 to 32,767 | %hd |
| unsigned short | 2 bytes | 0 to 65,535 | %hu |
| int | 4 bytes | -2.1B to 2.1B | %d |
| unsigned int | 4 bytes | 0 to 4.2B | %u |
| long | 4/8 bytes | Platform dependent | %ld |
| long long | 8 bytes | ±9.2 quintillion | %lld |
| float | 4 bytes | ±3.4E±38 (6 digits) | %f |
| double | 8 bytes | ±1.7E±308 (15 digits) | %lf |
%d, %iSigned integer%uUnsigned integer%fFloat (6 decimals)%.2fFloat (2 decimals)%e, %EScientific notation%cCharacter%sString%pPointer address%x, %XHexadecimal%oOctal%%Literal %%5dWidth 5, right align%-5dWidth 5, left align%05dZero-padded\nNewline\tTab\rCarriage return\\Backslash\"Double quote\'Single quote\0Null character\aBell/Alert\bBackspace+-*/%++--==!=<><=>=&&||!&|^~<<>>=+=-=*=/=%=#include <stdio.h>
int main() {
printf("Hello!\n");
return 0;
}int age = 25; float price = 19.99; char grade = 'A'; const int MAX = 100;
if (x > 0) {
// positive
} else if (x < 0) {
// negative
} else {
// zero
}switch (choice) {
case 1: break;
case 2: break;
default: break;
}for (int i = 0; i < n; i++) {
// code
}while (condition) {
// code
}int add(int a, int b) {
return a + b;
}int arr[5] = {1, 2, 3};
char str[] = "Hello";int x = 10;
int *ptr = &x;
printf("%d", *ptr);struct Point {
int x, y;
};
struct Point p = {1, 2};int *arr = malloc(n * sizeof(int));
if (arr) {
free(arr);
}FILE *f = fopen("file.txt", "r");
if (f) {
fclose(f);
}<stdio.h>printf, scanf, fopen, fclose, fgets
<stdlib.h>malloc, free, atoi, rand, exit
<string.h>strlen, strcpy, strcat, strcmp, strstr
<math.h>sqrt, pow, sin, cos, ceil, floor
<ctype.h>isalpha, isdigit, toupper, tolower
<time.h>time, clock, strftime, localtime
intcharfloatdoublevoidshortlongunsignedconstvolatilestaticexternregisterifelseswitchforwhiledobreakcontinuereturnstructunionenumtypedefsizeofNeed more details?
View Full Tutorials