main()

{

char *p;

printf("%d %d ",sizeof(*p),sizeof(p));

}

Answers were Sorted based on User's Feedback



main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }..

Answer / susie

Answer :

1 2

Explanation:

The sizeof() operator gives the number of bytes
taken by its operand. P is a character pointer, which needs
one byte for storing its value (a character). Hence
sizeof(*p) gives a value of 1. Since it needs two bytes to
store the address of the character pointer sizeof(p) gives 2.

Is This Answer Correct ?    16 Yes 7 No

main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }..

Answer / jha334201553

sizeof(*p) = sizeof(char) = 1
sizeof(p) = sizeof(void *)

I don't know the value of sizeof(p) .In deferent system the
value is deferent.In DOD, it's 2. int 32bits winNT, it's 4.
in 64bits WinNT, It's 8

Is This Answer Correct ?    6 Yes 0 No

main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }..

Answer / arif

1,8

Is This Answer Correct ?    5 Yes 1 No

main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }..

Answer / dilberphant

The results are indeterminate. The program code is in error.

1) The variadic function printf() requires an in-scope
prototype. No prototype for printf() has been provided.

2) main() is (by definition) a function that returns an
integer value. It is unclear which version of the C language
this program is intended to conform to, and for most
versions of the language, main() is required to include a
return <value>;
for some integer <value>

3) In a hosted environment, main() accepts either two
arguments (an int, and a char *[]) or none. Thus, either
main(int argc, char *argv[])
or
main(void)
are acceptable

4) The size of a pointer is dependant on operating platform
and C compiler implementation. The C language does not
define a "correct" value for sizeof (char *), and thus /any/
value for sizeof (char *) is acceptable (with the above
caveats about platform and compiler). The value is
unpredictable at a theoretical level.

Is This Answer Correct ?    2 Yes 1 No

main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }..

Answer / rajeev

1,4

Is This Answer Correct ?    4 Yes 3 No

main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }..

Answer / nikki

its 1 2

Is This Answer Correct ?    5 Yes 5 No

Post New Answer

More C Code Interview Questions

void main() { if(~0 == (unsigned int)-1) printf(“You can answer this if you know how values are represented in memory”); }

1 Answers  


main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; printf("\n%d %d %d",a,*f1,*f2); }

6 Answers  


main() { { unsigned int bit=256; printf("%d", bit); } { unsigned int bit=512; printf("%d", bit); } } a. 256, 256 b. 512, 512 c. 256, 512 d. Compile error

1 Answers   HCL,


main() { int i, n; char *x = “girl”; n = strlen(x); *x = x[n]; for(i=0; i<n; ++i) { printf(“%s\n”,x); x++; } }

2 Answers  


respected sir, i did my MCA in 2013 when i am going to attend to an interview i was asked about my project how will i explain my project could please help me in this and my project title is "Social Networking Site For Social Responsibility"

1 Answers   Genpact, Ozdocs,






What is "far" and "near" pointers in "c"...?

3 Answers  


program to Reverse a linked list

12 Answers   Aricent, Microsoft, Ness Technologies,


4. Main() { Int i=3,j=2,c=0,m; m=i&&j||c&I; printf(“%d%d%d%d”,I,j,c,m); }

2 Answers   Broadridge,


Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like.

21 Answers   ABC, eBay, Goldman Sachs, Google, HUP, Microsoft, TATA,


Print an integer using only putchar. Try doing it without using extra storage.

2 Answers  


Is the following code legal? typedef struct a { int x; aType *b; }aType

1 Answers  


what is variable length argument list?

2 Answers  


Categories