write a program for size of a data type without using
sizeof() operator?

Answers were Sorted based on User's Feedback



write a program for size of a data type without using sizeof() operator?..

Answer / mazhar shaikh

datatype a,*p,*q;
p=&a;
q=p+1;
cout<<abs(int(p)-int(q))<<endl;

Is This Answer Correct ?    5 Yes 7 No

write a program for size of a data type without using sizeof() operator?..

Answer / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
int integer[2],p;
float floating[2],q;
char character[2],r;
double doubling[2],s;
clrscr();
p=(integer+1)-integer;
q=(floating+1)-floating;
r=(character+1)-character;
s=(doubling+1)-doubling;
printf("the sizeof int is :%d",p);
printf("\nthe size of float is :%d",q);
printf("\nthe size of character is :%d",r);
printf("\nthe size of double is :%d",s);
getch();
}


thank u

Is This Answer Correct ?    5 Yes 11 No

Post New Answer

More C Interview Questions

What's the best way to declare and define global variables?

7 Answers  


2)#include<iostream.h> main() { printf("Hello World"); } the program prints Hello World without changing main() the o/p should be intialisation Hello World Desruct the changes should be a)iostream operator<<(iostream os, char*s) os<<'intialisation'<<(Hello World)<<Destruct b) c) d)none of the above

4 Answers   Siemens,


Look at the Code: main() { int a[]={1,2,3},i; for(i=0;i<3;i++) { printf("%d",*a); a++; } } Which Statement is/are True w.r.t the above code? I.Executes Successfully & Prints the contents of the array II.Gives the Error:Lvalue Required III.The address of the array should not be changed IV.None of the Above. A)Only I B)Only II C)II & III D)IV

5 Answers   Accenture,


pierrot's divisor program using c or c++ code

0 Answers  


What is #pragma statements?

0 Answers  






What is the scope of static variables in c language?

0 Answers  


what's the o/p int main(int n, char *argv[]) { char *s= *++argv; puts(s); exit(0); }

1 Answers   Motorola,


What is character constants?

0 Answers  


What are the languages are portable and platform independent?Why they are like that?

1 Answers   Excel, Satyam,


#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }

0 Answers   Wilco,


How can you find the day of the week given the date?

0 Answers  


2.Given the short c program that follows a. make a list of the memory variables in this program b.which lines of code contain operations that change the contents of memory? what are those operations? Void main( void) { Double base; Double height; Double area; Printf(“enter base and height of triangle :”); Scanf(“%lg”, &base); Scanf(“%lg”, &height); Area=base*height/2.0; Printf(“the area of the triangle is %g \n”,area); }

1 Answers   Wipro,


Categories