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

what are the facialities provided by you after the selection of the student.

0 Answers   TCS,


main() { char *p; p="Hello"; printf("%c\n",*&*p); }

2 Answers   ME,


Where are local variables stored in c?

0 Answers  


What is macro?

5 Answers   IBM,


#include<stdio.h> int main( ) { Int a=300, b, c; if(a>=400) b=300; c=200; printf(“%d%d ”, b, c); return0; }

1 Answers  


i want to have a program to read a string and print the frequency of each character and it should work in turbo c

3 Answers   Persistent, Wipro,


main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); }

11 Answers   CISOC, CitiGroup, College School Exams Tests,


Please provide question papers of NATIONAL INFORMATICS CENTRE for Scientific officer

0 Answers  


How can I check whether a file exists? I want to warn the user if a requested input file is missing.

0 Answers  


What do you mean by dynamic memory allocation in c? What functions are used?

0 Answers  


What is difference between scanf and gets?

0 Answers  


what is d pitfalls of registers variables

3 Answers   TCS,


Categories