Consider the following iterative implementation used to reverse a string:
#include<stdio.h>
#include<string.h>
void reverse_string(char *s)
{
int len = strlen(s);
int i,j;
i=0;
j=len-1;
while(______)
{
char tmp = s[i];
s[i] = s[j];
s[j] = tmp;
i++;
j--;
}
}
Which of the following lines should be inserted to complete the above code?
#include<stdio.h>
#include<string.h>
void reverse_string(char *s)
{
int len = strlen(s);
int i,j;
i=0;
j=len-1;
while(______)
{
char tmp = s[i];
s[i] = s[j];
s[j] = tmp;
i++;
j--;
}
}
A. i > j
B. i < len
C. j > 0
D. i < j
Answer: Option D
Join The Discussion