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));

}



main() { char *p="GOOD"; char a[ ]="GOOD"; printf(&qu..

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

Post New Answer

More C Code Interview Questions

union u { struct st { int i : 4; int j : 4; int k : 4; int l; }st; int i; }u; main() { u.i = 100; printf("%d, %d, %d",u.i, u.st.i, u.st.l); } a. 4, 4, 0 b. 0, 0, 0 c. 100, 4, 0 d. 40, 4, 0

1 Answers   HCL,


write a c program to print magic square of order n when n>3 and n is odd?

1 Answers   HCL,


Write a routine to implement the polymarker function

0 Answers   TCS,


plz send me all data structure related programs

2 Answers  


Write a program to implement the motion of a bouncing ball using a downward gravitational force and a ground-plane friction force. Initially the ball is to be projected in to space with a given velocity vector

2 Answers  






How can u say that a given point is in a triangle? 1. with the co-ordinates of the 3 vertices specified. 2. with only the co-ordinates of the top vertex given.

1 Answers  


main() { int i=10; void pascal f(int,int,int); f(i++,i++,i++); printf(" %d",i); } void pascal f(integer :i,integer:j,integer :k) { write(i,j,k); }

1 Answers  


#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d----%d",*p,*q); }

1 Answers  


find simple interest & compund interest

2 Answers  


Give a one-line C expression to test whether a number is a power of 2.

10 Answers   Microsoft,


Write a single line c expression to delete a,b,c from aabbcc

2 Answers   Microsoft,


main() { struct student { char name[30]; struct date dob; }stud; struct date { int day,month,year; }; scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month, &student.dob.year); }

1 Answers  


Categories