ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
struct ptr
{
int a;
char b;
int *p;
}abc;
what is d sizeof structure without using "sizeof" operator??
 Question Submitted By :: Vishnu948923
I also faced this Question!!     Rank Answer Posted By  
 
  Re: struct ptr { int a; char b; int *p; }abc; what is d sizeof structure without using "sizeof" operator??
Answer
# 1
11
 
Is This Answer Correct ?    3 Yes 14 No
Manoj Mishra
 
  Re: struct ptr { int a; char b; int *p; }abc; what is d sizeof structure without using "sizeof" operator??
Answer
# 2
void main()
{
int x,y;
y=&abc.a;
x=(&abc->p+1);
printf("%d",x-y);
}
 
Is This Answer Correct ?    6 Yes 3 No
Vishnu948923
[No]
 
 
 
  Re: struct ptr { int a; char b; int *p; }abc; what is d sizeof structure without using "sizeof" operator??
Answer
# 3
The total size would be 5.
Since 'int a' takes 2; 
'char b' takes 1; and
'int *p' takes 2 (Note: Any pointer variable would take 2 bytes)

There is no additional size of 'struct' data structure.
Hence 5 is the value.
 
Is This Answer Correct ?    6 Yes 6 No
Gagandeep
 
  Re: struct ptr { int a; char b; int *p; }abc; what is d sizeof structure without using "sizeof" operator??
Answer
# 4
THE SIZE OF THE STRUCTURE WILL BE '5'
 
Is This Answer Correct ?    1 Yes 4 No
Vignesh1988i
 
  Re: struct ptr { int a; char b; int *p; }abc; what is d sizeof structure without using "sizeof" operator??
Answer
# 5
The size of the structure is 5 bytes
 
Is This Answer Correct ?    2 Yes 2 No
Ryan
 
  Re: struct ptr { int a; char b; int *p; }abc; what is d sizeof structure without using "sizeof" operator??
Answer
# 6
the correct answer in gcc compiler is 12..
concept of structure padding is involved here..
 
Is This Answer Correct ?    4 Yes 1 No
Avinash Dubey
 
  Re: struct ptr { int a; char b; int *p; }abc; what is d sizeof structure without using "sizeof" operator??
Answer
# 7
12 is answer
 int a takes 4 bytes
 char b takes 4 bytes due to data padding
 int *p any pointer takes 4 bytes
so totally 12 bytes........
 
Is This Answer Correct ?    0 Yes 1 No
Kk
 
  Re: struct ptr { int a; char b; int *p; }abc; what is d sizeof structure without using "sizeof" operator??
Answer
# 8
In Linux, its 12 bytes.
int a   ------- 4 bytes
char b  ------- 1 byte.
but as the next element is integer, it wont fit in the 
remaining 3 bytes left after the "char b" occupies the first byte of the 4 byte chunk. so these 3 bytes wont be used for storing "int *p". these will be padded. next 4 bytes will be used for storing *p.

to prove it.

int size;
size = (&(abc.p) + sizeof(abc.p)) - &abc.a ;
printf("size = %d",size);
 
Is This Answer Correct ?    0 Yes 0 No
Pradeep
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
Given an unsigned integer, find if the number is power of 2?  3
is compiler do read the data line by line or not. ?? LG-Soft3
how to find the binary of a number? Infosys5
Look at the Code: #include<string.h> void main() { char s1[]="abcd"; char s2[10]; char s3[]="efgh"; int i; clrscr(); i=strcmp(strcat(s3,ctrcpy(s2,s1))strcat(s3,"abcd")); printf("%d",i); } What will be the output? A)No output B) A Non Integer C)0 D) Garbage Accenture5
What will be printed as the result of the operation below: #include<..> int x; int modifyvalue() { return(x+=10); } int changevalue(int x) { return(x+=1); } void main() { int x=10; x++; changevalue(x); x++; modifyvalue(); printf("First output:%d\n",x); x++; changevalue(x); printf("Second output:%d\n",x); modifyvalue(); printf("Third output:%d\n",x); }  2
how to find the size of the data type like int,float without using the sizeof operator?  7
main() {int a=200*200/100; printf("%d",a); } TCS7
what is the difference between #include<> and #include”…”?  1
#include<stdio.h> int fun(); int i; int main() { while(i) { fun(); main(); } printf("hello \n"); return 0; } int fun() { printf("hi"); } answer is hello.how??wat is tat while(i) mean? Intel4
What is external and internal variables What is dynamic memory allocation what is storage classes in C  2
what does the following code do? fn(int n,int p,int r) { static int a=p; switch(n){ case 4:a+=a*r; case 3:a+=a*r; case 2:a+=a*r; case 1:a+=a*r; } } a.computes simple interest for one year b.computes amount on compound interest for 1 to 4 years c.computes simple interest for four year d.computes compound interst for 1 year TCS4
Determine if a number is a power of 2 at O(1).  1
write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! =1+24+120 =145]  2
here is a link to download Let_Us_C_-_Yashwant_Kanetkar  2
what is the use of call back function in c?tell me with example  1
what are the difference between ANSI C and Let Us c and Turbo C LG-Soft1
How can I invoke another program from within a C program?  6
void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); } ME3
Dear Sir, we are required the bubble sorting programs Regs Prem  1
Write a C program to print 1 2 3 ... 100 without using loops?  5
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com