-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
62 lines (46 loc) · 1.35 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <stdio.h>
#include <stdlib.h>
/* Project 68
Studying C Types (char, int, float & double)
This program show:
How to get the type of a variable in C code?
*****************************
Output:
Char -> 1 Byte(s)
int -> 4 Byte(s)
float -> 4 Bytes(s)
double -> 8 Byte(s)
long double 16 Byte(s)
The Default C type is: int
*****************************
. C Rule n 1 - no variable can assume the same char value;
. C Rule n 2 - the absence of modifiers forces the compiler to use the signed;
. C Rule n 3 - int is the standard type;
. C Rule n 4 - if you don't indicate the type, the compiler assumes int;
Compiler: Dev C ++ Version 2 - Jun,1991
(https://sourceforge.net/projects/orwelldevcpp/)
Author: j3
date: jun, 08/2021
*/
int main() {
char a;
int b;
float c;
double d;
long double e;
signed f;
printf("Char -> %d Byte(s)\n", sizeof(a));
printf("int -> %d Byte(s)\n", sizeof(b));
printf("float -> %d Bytes(s)\n", sizeof(c));
printf("double -> %d Byte(s)\n", sizeof(d));
printf("long double %d Byte(s)\n", sizeof(e));
/* if you don't indicate the type the compiler assumes int */
printf("The Default C type is: ");
if(sizeof(f)==sizeof(char))
printf("char");
else if(sizeof(f)==sizeof(int))
printf("int");
else if(sizeof(f)==sizeof(double))
printf("double");
return 0;
}