main()
{
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));
}
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
¦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...
x=2 y=3 z=2 x++ + y++; printf("%d%d" x,y);
Write a procedure to implement highlight as a blinking operation
What is your nationality?
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }
main() { static int a[3][3]={1,2,3,4,5,6,7,8,9}; int i,j; static *p[]={a,a+1,a+2}; for(i=0;i<3;i++) { for(j=0;j<3;j++) printf("%d\t%d\t%d\t%d\n",*(*(p+i)+j), *(*(j+p)+i),*(*(i+p)+j),*(*(p+j)+i)); } }
func(a,b) int a,b; { return( a= (a==b) ); } main() { int process(),func(); printf("The value of process is %d !\n ",process(func,3,6)); } process(pf,val1,val2) int (*pf) (); int val1,val2; { return((*pf) (val1,val2)); }
main( ) { void *vp; char ch = ‘g’, *cp = “goofy”; int j = 20; vp = &ch; printf(“%c”, *(char *)vp); vp = &j; printf(“%d”,*(int *)vp); vp = cp; printf(“%s”,(char *)vp + 3); }
main() { int i = 258; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }
How to use power function under linux environment.eg : for(i=1;i<=n;i++){ pow(-1,i-1)} since it alerts undefined reference to 'pow'.
There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.
#define a 10 int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } void foo() { #undef a #define a 50 }