Thursday, 16 May 2019
Wednesday, 15 May 2019
Tuesday, 14 May 2019
The Interview Question Today#27(26-3-19)(Size of structure)
May 14, 2019C interview Question, C Question Group 0, Interview, Size of structure, Technical RoundNo comments
Question:
Write a c program to find the size of structure without using sizeof operator?
Solution:
C program:
#include<stdio.h>
struct XYZ{
int x;
float y;
char z;
};
int main(){
int sz = (int) (((struct XYZ *)0) + 1);
printf("Size of Struct= %d",sz);
return 0;
}
Write a c program to find the size of structure without using sizeof operator?
Solution:
C program:
#include<stdio.h>
struct XYZ{
int x;
float y;
char z;
};
int main(){
int sz = (int) (((struct XYZ *)0) + 1);
printf("Size of Struct= %d",sz);
return 0;
}
Output:
Size of Struct= 12


















