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 ?    15 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

What is the output for the following program main() { int arr2D[3][3]; printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) ); }

1 Answers  


main() { int i=-1; +i; printf("i = %d, +i = %d \n",i,+i); }

1 Answers  


main() { 41printf("%p",main); }8

1 Answers  


write a program to Insert in a sorted list

4 Answers   Microsoft,


#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }

2 Answers  






¦void main() ¦{ ¦int i=10,j; ¦ j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-30 but in same question if we write as- ¦void main() ¦{ ¦int i=10; ¦ int j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-33 why output is changed from 30 to 33. Can any body answer...

3 Answers  


write a program for area of circumference of shapes

0 Answers  


Display the time of the system and display the right time of the other country

1 Answers  


void ( * abc( int, void ( *def) () ) ) ();

1 Answers  


Cluster head selection in Wireless Sensor Network using C programming language.

0 Answers  


void main() { int x,y=2,z; z=(z*=2)+(x=y=z); printf("%d",z); }

4 Answers  


int aaa() {printf(“Hi”);} int bbb(){printf(“hello”);} iny ccc(){printf(“bye”);} main() { int ( * ptr[3]) (); ptr[0] = aaa; ptr[1] = bbb; ptr[2] =ccc; ptr[2](); }

1 Answers  


Categories