how to find the size of the data type like int,float
without using the sizeof operator?

Answers were Sorted based on User's Feedback



how to find the size of the data type like int,float without using the sizeof operator?..

Answer / abhishek pathak mnnit

#include <stdio.h>
#define sizeof(x) ((void *)(&x + 1) - (void *)(&x))
void main()
{
int a;
printf("int size=%d",sizeof(a));
}

Is This Answer Correct ?    3 Yes 8 No

how to find the size of the data type like int,float without using the sizeof operator?..

Answer / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
int ptr,a[2];
char ptr1,b[2];
float ptr2,c[2];
ptr=(a+1)-a;
ptr1=(b+1)-b;
ptr2=(c+1)-c;
printf("int : %d\n",ptr);
printf("char : %d\n",ptr1);
printf('float : %d\n",ptr2);
getch();
}


than ku

Is This Answer Correct ?    0 Yes 8 No

how to find the size of the data type like int,float without using the sizeof operator?..

Answer / ravi.jnv

Its possible by pointers.
-----------------
int one,two;
int *ptrOfOne,*ptrOfTwo;
int size;
ptrOfOne = &one;
ptrOfTwo = &two;
size = ptrOfOne - ptrOfTwo ; /* u can get minus value also
depending upon stack how it pushes variables */

Is This Answer Correct ?    6 Yes 28 No

Post New Answer

More C Interview Questions

Whether there can be main inside another main?If so how does it work?

14 Answers   Sail, Wipro,


inline function is there in c language?

4 Answers  


Explain what are header files and explain what are its uses in c programming?

0 Answers  


Explain the process of converting a Tree into a Binary Tree.

0 Answers   Ignou,


write a program to generate 1st n fibonacci prime number

12 Answers  






hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?

0 Answers   HCL,


Where are the auto variables stored?

0 Answers   TISL,


Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors

3 Answers  


sqrt(x+sqrt(x+sqrt(x+sqrt(x))))=2; Find the value of x?

4 Answers   Subex,


Explain how do you declare an array that will hold more than 64kb of data?

0 Answers  


a=0; b=(a=0)?2:3; a) What will be the value of b? why b) If in 1st stmt a=0 is replaced by -1, b=? c) If in second stmt a=0 is replaced by -1, b=?

6 Answers   Geometric Software,


How can I find out the size of a file, prior to reading it in?

0 Answers  


Categories