Exercise: Reverse the Words

Write code to solve the problem.

Question

Write code to reverse the order of words in the string variable sentence. The characters inside each word should remain unchanged. Only the order of the words should be reversed.

Sample input:

char sentence[] = "C programming is fun";

Sample output:

fun is programming C

Exercise: Reverse the Words

Write code to solve the problem.

Question

Write code to reverse the order of words in the string variable sentence. The characters inside each word should remain unchanged. Only the order of the words should be reversed.

Sample input:

char sentence[] = "C programming is fun";

Sample output:

fun is programming C
C
#include <stdio.h>
#include <string.h>
int main() {
char sentence[] = "C programming is fun";
int len = strlen(sentence);
/* Write your code here */
printf("%s\n", sentence);
return 0;
}