Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

C | String | Question 15

  • Last Updated : 28 Jun, 2021

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

Take a step-up from those "Hello World" programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.




#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


Answer: (B)

Explanation: str1 is a pointer and str2 is an array.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :