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 Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

create a C-code that will display the total fare of a passenger of a taxi if the driver press enter,the timer will stop. Every 10 counts is 2 pesos. Initial value is 25.00

6605


write a program for area of circumference of shapes

2251


Design an implement of the inputs functions for event mode

3192


why nlogn is the lower limit of any sort algorithm?

2558


How to palindrom string in c language?

9863


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

3405


What is full form of PEPSI

2136


why do you use macros? Explain a situation where you had to incorporate macros in your proc report? use a simple instream data example with code ?

2524


write a simple calculator c program to perform addition, subtraction, mul and div.

3397


What is data _null_? ,Explain with code when u need to use it in data step programming ?

3034


Sir... please give some important coding questions asked by product companies..

2040


In a gymnastic competition, scoring is based on the average of all scores given by the judges excluding the maximum and minimum scores. Let the user input the number of judges, after that, input the scores from the judges. Output the average score. Note: In case, more than two judges give the same score and it happens that score is the maximum or minimum then just eliminate two scores. For example, if the number of judges is 5 and all of them give 10 points each. Then the maximum and minimum score is 10. So the computation would be 10+10+10, this time. The output should be 10 because 30/3 is 10.

2650


How can you relate the function with the structure? Explain with an appropriate example.

3138


Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange

3090


Can you send Code for Run Length Encoding Of BMP Image in C Language in linux(i.e Compression and Decompression) ?

4093