Q. Determine Output:

Code:
void main()
{
      char *p;
      printf("%d %d", sizeof(*p), sizeof(p));
}
  • (A) 1 1
  • (B) 1 2
  • (C) 2 1
  • (D) 2 2
πŸ’¬ Discuss
βœ… Correct Answer: (B) 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.
Explanation by: Prashant
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.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
219
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Prashant
Publisher
πŸ“ˆ
90%
Success Rate