Knowee
Questions
Features
Study Tools

What is the output of the following code ?#include <stdio.h>#include <string.h>int main() {    char str1[] = "Hello";    char str2[] = "World";    char str3[20];    strcpy(str3, strrev(strcat(str1, str2)));    printf("%s", str3);    return 0;}

Question

What is the output of the following code ?#include <stdio.h>#include <string.h>int main() {    char str1[] = "Hello";    char str2[] = "World";    char str3[20];    strcpy(str3, strrev(strcat(str1, str2)));    printf("%s", str3);    return 0;}

🧐 Not the exact question you are looking for?Go ask a question

Solution

The output of the code will be "dlroWolleH".

Here's the step by step explanation:

  1. The code declares three character arrays: str1, str2, and str3. str1 is initialized with the string "Hello", and str2 is initialized with the string "World". str3 is an empty array with a size of 20 characters.

  2. The strcat function concatenates str1 and str2, resulting in str1 being "HelloWorld".

  3. The strrev function reverses the string "HelloWorld" to "dlroWolleH".

  4. The strcpy function copies the reversed string "dlroWolleH

This problem has been solved

Similar Questions

What will be the output of the following code snippet?

What is the output of the following code in Python?

What will be the output of the following C code?

What is the output for the following code?Note: This question helps in clearing conceptual technical interviews for service-based companies.

What will be the output of the following C++ code?

1/4

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.