write a program to reverse a every alternetive words in a
string in a place.
EX: Input is "this is the line of text"
Output should be "shit is eht line fo text"
Please any one tell me code for that.



write a program to reverse a every alternetive words in a string in a place. EX: Input is "t..

Answer / Sana Parveen

Here's an example C code for the given problem:
```c
#include <stdio.h>
#include <string.h>

void reverse_word(char *str, int index) {
int len = strlen(str);
if (index >= len / 2) return;

char temp = str[index];
str[index] = str[len - index - 1];
str[len - index - 1] = temp;

reverse_word(str, index + 1);
}

int main() {
char input[] = "this is the line of text";
reverse_word(input, 0);
printf("%s", input);
return 0;
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Is main is user defined function?

1 Answers  


write a program that will print %d in the output screen??

9 Answers   Infosys,


What does 3 mean in texting?

1 Answers  


When you call malloc() to allocate memory for a local pointer, do you have to explicitly free() it?

2 Answers   Aloha Technology,


AMMONG THE 4 STROAGE CLASSES IN C, WHICH ONE FASTEST?

13 Answers   HCL,


in linking some of os executables are linking name some of them

1 Answers   IBM,


Do you know the use of fflush() function?

1 Answers  


how can we Declare a variable in c without defining it.

1 Answers   TCS,


what is the difference between getch() and getche()?

7 Answers   Infosys,


What is the scope of static variable in c?

1 Answers  


Explain how do you determine a file’s attributes?

1 Answers  


what is diference between return 0 and return NULL??

3 Answers  


Categories