write a program for size of a data type without using
sizeof() operator?
Answer Posted / govind279
#include<stdio.h>
int main()
{
int n;
int x,*p,*p1;/* here u can change the type */
p=&x;
p1=(p+1);
printf("size of x is : %d\n",n=(char *)(p1)-(char *)p);
}
Note:without type cast, it always gives 1.
i.e 1 int(4 chars), 1 float(4 chars),1 double(8
chars)etc...coz p+1 points to the next new location of same
type.
| Is This Answer Correct ? | 40 Yes | 9 No |
Post New Answer View All Answers
What is call by reference in functions?
Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.
What is the correct declaration of main?
What is the meaning of typedef struct in c?
A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler
What is extern storage class in c?
Difference between Shallow copy and Deep copy?
what are the different storage classes in c?
main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }
What is time complexity c?
formula to convert 2500mmh2o into m3/hr
What is a node in c?
What is %g in c?
Explain what are run-time errors?
What are the benefits of organizational structure?