#include<stdio.h>
#include<stdlib.h>
#define N 50
void print_word(char* str, int i, int j);
int main(void)
{
char ch;
char str[N] = { ' ' };
printf("Eter a sentence: ");
ch = getchar();
for (int i = 1;
i < N && ch != '.' && ch != '?' && ch != '!';
i++)
{
str[i] = ch;
ch = getchar();
}
printf("Reversal of sentence:");
int i, j;
for (i = N-1; str[i] == 0; i--)
;
while (i > 0)
{
for (j = i; str[j] != ' '; j--)
;
print_word(str, i, j);
i = j-1;
}
printf("%c", ch);
return 0;
}
void print_word(char* str, int i, int j)
{
while (j <= i)
{
printf("%c", str[j]);
j++;
}
}