Q. Predict the output of following program, assume that a character takes 1 byte and pointer takes 4 bytes.

Code:
#include <stdio.h>
int main()
{
    char *str1 = "GeeksQuiz";
    char str2[] = "GeeksQuiz";
 
    printf("sizeof(str1) = %d, sizeof(str2) = %d",
           sizeof(str1), sizeof(str2));
 
    return 0;
}
  • (A) sizeof(str1) = 10, sizeof(str2) = 10
  • (B) sizeof(str1) = 4, sizeof(str2) = 10
  • (C) sizeof(str1) = 4, sizeof(str2) = 4
  • (D) sizeof(str1) = 10, sizeof(str2) = 4
πŸ’¬ Discuss
βœ… Correct Answer: (B) sizeof(str1) = 4, sizeof(str2) = 10

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
256
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Ram Sharma
Publisher
πŸ“ˆ
87%
Success Rate