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 / sunil

This has been solved in parts. I am not sure if there are
any better method merging it.

case 1. User passes a variable as the parameter.
eg: int n;
sizeof(n);

case 2. User passes a data type as the parameter.
eg: sizeof(int)


Solution
case 1: #define GetSize(x) (char*)(&x + 1) - (char*)&x

case 2:#define GetMySize(x) (char*)((x*)10 + 1) - (char*)10

Is This Answer Correct ?    15 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

2279


Can you subtract pointers from each other? Why would you?

920


why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above

1031


What is array in c with example?

1169


How is a pointer variable declared?

1027


What are the advantages and disadvantages of a heap?

1149


Why structure is used in c?

1116


if p is a string contained in a string?

1798


How do you write a program which produces its own source code as output?

1063


Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?

1447


Explain what is the advantage of a random access file?

1069


What is getch?

1095


What is typedef struct in c?

1003


A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM

2080


#include #include struct stu { int i; char j; }; union uni { int i; char j; }; void main() { int j,k; clrscr(); struct stu s; j=sizeof(s); printf("%d",j); union uni u; k=sizeof(u); printf("%d",k); getch(); } what is value of j and k.

6195