Examveda

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?

A. i > j

B. i < len

C. j > 0

D. i < j

Answer: Option D


This Question Belongs to Data Structure >> Miscellaneous On Data Structures

Join The Discussion

Related Questions on Miscellaneous on Data Structures