Skip to content
Related Articles

Related Articles

Improve Article

C | String | Question 16

  • Last Updated : 28 Jun, 2021

Output of following C program? Assume that all necessary header files are included

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.




int main()
{
    char *s1 = (char *)malloc(50);
    char *s2 = (char *)malloc(50);
    strcpy(s1, "Geeks");
    strcpy(s2, "Quiz");
    strcat(s1, s2);
    printf("%s", s1);
    return 0;
}

(A) GeeksQuiz
(B) Geeks
(C) Geeks Quiz
(D) Quiz


Answer: (A)

Explanation: strcpy puts \0 at the end.

strcat starts from \0, concatenates string and puts \0 at the end.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :