Program for Reversing a line of text

#include
#include

void main()
{
char str[80],ch;
int len=0,i=0;
clrscr();
printf("\n\n\n\t\t\t Program for Reversing a line of text");


printf("\n\n\n\t\t\t Enter a line of Text:");
printf("\n\t >> ");
fflush(stdin);
scanf("%[^'\n']",str);


i=0;

while(str[i]!='\0')
{
len++;
i++;
}

len=len-1;

printf("\n\n\t Reverse = ");

for(i=len;i>=0;i--)
{
ch=str[i];
if(ch>=97 && ch<=123)
ch=ch-32;
printf("%c",ch);
}




getch();
}

No comments:

Post a Comment