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
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
Can you subtract pointers from each other? Why would you?
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
What is array in c with example?
How is a pointer variable declared?
What are the advantages and disadvantages of a heap?
Why structure is used in c?
if p is a string contained in a string?
How do you write a program which produces its own source code as output?
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?
Explain what is the advantage of a random access file?
What is getch?
What is typedef struct in c?
A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM
#include