main()
{
char *p="GOOD";
char a[ ]="GOOD";
printf("\n sizeof(p) = %d, sizeof(*p) = %d, strlen(p) = %d",
sizeof(p), sizeof(*p), strlen(p));
printf("\n sizeof(a) = %d, strlen(a) = %d",
sizeof(a), strlen(a));
}
Answer / susie
Answer :
sizeof(p) = 2, sizeof(*p) = 1, strlen(p) = 4
sizeof(a) = 5, strlen(a) = 4
Explanation:
sizeof(p) => sizeof(char*) => 2
sizeof(*p) => sizeof(char) => 1
Similarly,
sizeof(a) => size of the character array => 5
When sizeof operator is applied to an array it returns the
sizeof the array and it is not the same as the sizeof the
pointer variable. Here the sizeof(a) where a is the
character array and the size of the array is 5 because the
space necessary for the terminating NULL character should
also be taken into account.
Is This Answer Correct ? | 1 Yes | 1 No |
Which version do you prefer of the following two, 1) printf(“%s”,str); // or the more curt one 2) printf(str);
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,
Who could write how to find a prime number in dynamic array?
Implement a t9 mobile dictionary. (Give code with explanation )
1 Answers Amazon, Peak6, Yahoo,
main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); }
main() { signed int bit=512, i=5; for(;i;i--) { printf("%d\n", bit = (bit >> (i - (i -1)))); } } a. 512, 256, 128, 64, 32 b. 256, 128, 64, 32, 16 c. 128, 64, 32, 16, 8 d. 64, 32, 16, 8, 4
main() { float i=1.5; switch(i) { case 1: printf("1"); case 2: printf("2"); default : printf("0"); } }
void main() { int *i = 0x400; // i points to the address 400 *i = 0; // set the value of memory location pointed by i; }
#define f(g,g2) g##g2 main() { int var12=100; printf("%d",f(var,12)); }
main( ) { int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}}; printf(“%u %u %u %d \n”,a,*a,**a,***a); printf(“%u %u %u %d \n”,a+1,*a+1,**a+1,***a+1); }
How to access command-line arguments?
how to concatenate the two strings