C program to reverse order of words in a string using while loop.
C program to reverse order of words in a string using while loop.
#include <stdio.h>
#include <string.h>
#define MAX 100
int main()
{
char text[MAX], res[MAX];
int test;
printf("Enter any string: ");
gets(text);
strcpy(res, text);
strrev(res);
test = strcmp(text, res);
if(test == 0)
{
printf("\n Enter String is Palindrome.");
}
else
{
printf("\n Enter String is Not Palindrome.");
}
return 0;
}
Output:
Enter any string: This is computer.
Original string : This is computer.
Reverse ordered words the given string: computer. is This