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 func1(int (*a)[10]) { printf("Ok it works"); } void func2(int a[][10]) { printf("Will this work?"); } main() { int a[10][10]; func1(a); func2(a); } a. Ok it works b. Will this work? c. Ok it worksWill this work? d. None of the above

1 Answers   HCL,


#include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s=malloc(sizeof(struct xx)); printf("%d",s->x); printf("%s",s->name); }

1 Answers   TCS,


void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }

2 Answers  


struct aaa{ struct aaa *prev; int i; struct aaa *next; }; main() { struct aaa abc,def,ghi,jkl; int x=100; abc.i=0;abc.prev=&jkl; abc.next=&def; def.i=1;def.prev=&abc;def.next=&ghi; ghi.i=2;ghi.prev=&def; ghi.next=&jkl; jkl.i=3;jkl.prev=&ghi;jkl.next=&abc; x=abc.next->next->prev->next->i; printf("%d",x); }

1 Answers  


main() { char str1[] = {‘s’,’o’,’m’,’e’}; char str2[] = {‘s’,’o’,’m’,’e’,’\0’}; while (strcmp(str1,str2)) printf(“Strings are not equal\n”); }

1 Answers  






How can i find first 5 natural Numbers without using any loop in c language????????

2 Answers   Microsoft,


main() { printf("%x",-1<<4); }

3 Answers   HCL, Sokrati, Zoho,


main() { int i =10, j = 20; clrscr(); printf("%d, %d, ", j-- , --i); printf("%d, %d ", j++ , ++i); } a. 20, 10, 20, 10 b. 20, 9, 20, 10 c. 20, 9, 19, 10 d. 19, 9, 20, 10

4 Answers   HCL,


write a program to count the number the same (letter/character foreg: 's') in a given sentence.

2 Answers  


Write a program using one dimensional array to assign values and then display it on the screen. Use the formula a[i]=i*10 to assign value to an element.

1 Answers   Samar State University,


{ int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }

4 Answers  


Write a Program in 'C' To Insert a Unique Number Only. (Hint: Just Like a Primary Key Numbers In Database.) Please Some One Suggest Me a Better Solution for This question ??

0 Answers   Home,


Categories