Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is scanf_s in c?

1074


What extern c means?

941


What is pointer to pointer in c?

1071


What is the difference between test design and test case design?

2041


What is a nested formula?

1068


How #define works?

1059


Explain what is a const pointer?

1043


What is a substring in c?

1002


When is a null pointer used?

1068


Is it possible to pass an entire structure to functions?

951


Explain how many levels deep can include files be nested?

1037


Why is event driven programming or procedural programming, better within specific scenario?

2377


find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

1960


what is the difference between 123 and 0123 in c?

1165


What is a function simple definition?

1042