what will be the value of x for the following code snippet?
char str1[]="dills";
char str2[20]="hello";
char str3[]="daffo";
int x;
x=strcmp("daffodills",strcat(str3,strcpy(str1,str2)));
Answers
Answered by
2
Hello daffodills
(though it is spelled as daffodils)
chandanam0310:
plzz check once its is so improtant
Answered by
0
In this program the output of the following code snippet will be "-4". The reason is very simple, when "strcmp" function is used to compare two strings, what happens is just the ASCII code of the words to be compared are subtracted, and the difference is returned, whenever the difference is any non zero number.
Here the in the code the first character with mismatch has a difference of 4, so the value of shall become -4.
Similar questions
World Languages,
7 months ago
Math,
7 months ago
Biology,
1 year ago
Social Sciences,
1 year ago
Social Sciences,
1 year ago