Vidyalelo
Data Structure · Q1048

Miscellaneous on Data Structures

Programming · Data Structure · question 1048

Q1048

What does the following code do? #include #include void reverse_string(char *s) int len = strlen(s); int i,j; i=0; j=len-1; while(i < j) char tmp = s[i]; s[i] = s[j]; s[j] = tmp; i++; j--; int main() char s[100] = "abcdefg"; char t[100]; strcpy(t,s); reverse_string(s); if(strcmp(t,s) == 0) printf("Yes"); else printf("No"); return 0;

A.
Copies a string to another string
B.
Compares two strings
C.
Reverses a string
D.
Checks if a string is a palindrome
Answer

Answer: Option D

Solution

Answer: Option D
No explanation is given for this question Let's Discuss on Board