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
in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.
Explain what is wrong with this program statement?
Which is more efficient, a switch statement or an if else chain?
What is memcpy() function?
What are global variables and how do you declare them?
What are the different types of C instructions?
What is sizeof int in c?
Why is sizeof () an operator and not a function?
Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;
What is the stack in c?
Explain how does free() know explain how much memory to release?
Explain union.
What is the process of writing the null pointer?
to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?
how is the examination pattern?