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
One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.
a program that can input number of records and can view it again the record
What is the difference between Printf(..) and sprint(...) ?
How do you search data in a data file using random access method?
if (i = 0)printf ("True"); elseprintf("False"); Under what conditions will the above print out the string "True" a) Never b) Always c) When the value of i is 0 d) all of the above
Write a program to swap two numbers without using third variable in c?
What is a stream in c programming?
what is bit rate & baud rate? plz give wave forms
Explain what are multibyte characters?
What is a function simple definition?
Differentiate abs() function from fabs() function.
What is calloc in c?
Explain about block scope in c?
What does the file stdio.h contain?
How can I do graphics in c?