Warning: implode(): Invalid arguments passed in /www/wwwroot/jobquiz.info/mdiscuss.php on line 336 What will be the output of the program ? #include<stdio.h> #include<string.h> int main() { char str1[20] = "Hello", str2[20] = " World"; printf("%s\n", strcpy(str2, strcat(str1, str2))); return 0; } ?->(Show Answer!)
1. What will be the output of the program ? #include<stdio.h> #include<string.h> int main() { char str1[20] = "Hello", str2[20] = " World"; printf("%s\n", strcpy(str2, strcat(str1, str2))); return 0; }
Ask Your Doubts Here
Comments
By: guest on 01 Jun 2017 06.02 pm
Step 1: char str1[20] = "Hello", str2[20] = " World"; The variable str1 and str2 is declared as an array of characters and initialized with value "Hello" and " World" respectively. Step 2: printf("%s\n", strcpy(str2, strcat(str1, str2))); => strcat(str1, str2)) it append the string str2 to str1. The result will be stored in str1. Therefore str1 contains "Hello World". => strcpy(str2, "Hello World") it copies the "Hello World" to the variable str2. Hence it prints "Hello World".