/************************************************************************
*																		*
* ders 10 ornekleri - Deniz Demiray										*
* cumleyi kelimelerine ayirip tersten yazan program						*
* derlemek icin gcc -o program_ismi 6.c									*
*																		*
************************************************************************/

#include <stdio.h>
#include <stdlib.h>

int main()
{
	
	char sentence[70], *temp, *end;
	printf("Enter a sentence:\n");
	gets(sentence); 
		
	end = sentence;
	
	printf("\nThe sentence:\n");
	
	while (*end != '\0') {
		putchar(*end);       //printf("%c", *end);
		end++;
	}
	  
		printf("\n\nThe words in the sentence in reverse order:\n");    
	    
    while (end != sentence )  {
    	
    	if (*end == ' ')  {
    		
    		temp=end+1;
    		
    		while ((*temp != ' ') && (*temp != '\0')) {
			
    	        putchar(*temp);     //printf("%c", *temp);
				temp++;
				
			}
    	     printf(" ");
		}
    	
		end--;      
    }
    
    while ((*end != ' ') && (*end != '\0')) {
		printf("%c", *end);
		end++;
	}
    
    printf("\n");
	
	system("pause");
	
	return 0;	
}
