-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path41_sizeof_micro.c
More file actions
56 lines (53 loc) · 1.16 KB
/
Copy path41_sizeof_micro.c
File metadata and controls
56 lines (53 loc) · 1.16 KB
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
/*
* Author: Girish Gaude
* Date: 21/Jan/2020
* Desciption: Program to perform size of using micro
* Input: Enter datatype
* Output: Display size of datatype
*/
#include<stdio.h>
#include<stdio_ext.h>
#define MY_SIZEOF(num) (char*)(&num+1) - (char*)(&num)
int main() //Define micro
{
char ch;
do
{
int opt;
printf("Please Select the datatype\n\t1.char\n\t2.int\n\t3.float\n\t4.double\n");
scanf("%d", &opt);
switch(opt) //Ask option for input
{
case 1: //If char
{
char num;
printf("Sizeof = %lu\n", MY_SIZEOF(num)); //Replace micro
break;
}
case 2: //IF int
{
int num1;
printf("Sizeof = %lu\n", MY_SIZEOF(num1)); //Replace micro
break;
}
case 3:
{
float num2; //IF float
printf("Sizeof = %lu\n", MY_SIZEOF(num2)); //Replace micro
break;
}
case 4: //IF double
{
double num3;
printf("Sizeof = %lu\n", MY_SIZEOF(num3)); //replace micro
break;
}
default:
printf("Please check the input\n");
}
printf("Do you want to continue.\n");
__fpurge(stdin);
scanf("%c", &ch);
}while( ch == 'y' ); //continue again
return 0;
}