write a program for size of a data type without using
sizeof() operator?
Answer Posted / p sahana upadhya
#include<stdio.h>
#include<math.h>
main()
{
float size;
printf("The Size of Integer Data Type is %d
Bytes\n",(sizeof(int)));
size=pow(2,(sizeof(int)*8));
printf("The Range of Integer Data Type is -%.0f to
%.0f\n\n",(size/2),((size/2)-1));
printf("The Size of Long Integer Data Type is %d
Bytes\n",(sizeof(long int)));
size=pow(2,(sizeof(long int)*8));
printf("The Range of Long Integer Data Type is -%.0f
to %.0f\n\n",(size/2),((size/2)-1));
printf("The Size of Unsigned Long Data Type is %d
Bytes\n",(sizeof(long int)));
size=pow(2,(sizeof(long int)*8));
printf("The Range of Unsigned Long Data Type is 0 to
%.0f\n\n",size);
printf("The Size of Float Data Type is %d Bytes\n",
(sizeof(float)));
size=pow(2,(sizeof(float)*8));
printf("The Range of Float Data Type is -%.0f to
%.0f\n\n",(size/2),((size/2)-1));
printf("The Size of Double Data Type is %d Bytes\n",
(sizeof(double)));
size=pow(2,(sizeof(double)*8));
printf("The Range of Double Data Type is -%.0f to
%.0f\n\n",(size/2),((size/2)-1));
printf("The Size of Long Double Data Type is %d
Bytes\n",(sizeof(long double)));
size=pow(2,(sizeof(long double)*8));
printf("The Range of Long Double Data Type is -%.0f
to %.0f\n\n",(size/2),((size/2)-1));
printf("The Size of Char Data Type is %d Bytes\n",
(sizeof(char)));
size=pow(2,(sizeof(char)*8));
printf("The Range of Character Data Type is -%.0f to
%.0f\n\n",(size/2),((size/2)-1));
printf("The Size of Unsigned Char Data Type is %d
Bytes\n",(sizeof(char)));
size=pow(2,(sizeof(char)*8));
printf("The Range of Unsigned Char Data Type is 0 to
%.0f\n\n",size);
getch();
return 0;
}
This program may seems long, but it definitely works!!!!!
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
What is scanf_s in c?
What extern c means?
What is pointer to pointer in c?
What is the difference between test design and test case design?
What is a nested formula?
How #define works?
Explain what is a const pointer?
What is a substring in c?
When is a null pointer used?
Is it possible to pass an entire structure to functions?
Explain how many levels deep can include files be nested?
Why is event driven programming or procedural programming, better within specific scenario?
find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2
what is the difference between 123 and 0123 in c?
What is a function simple definition?