#include
#include
main()
{
char ch,name[20];
int i=0;
clrscr();
printf(\"Enter a string:\");
while((ch=getch())!=
The keyboard return key is the carriage return, or CR. This is found by running the program and analyzing the results.
When you press enter key, the ASCII value of Enter key is not returned, instead CR is returned.
Hence (ch=getch())!='\n' should be changed to any of the following equivalent statements:
ch=getch())!='\r'
ch=getch())!=13 // ASCII for CR: decimal
ch=getch())!=0xd // hexadecimal for CR
ch=getch())!=0xD // hexadecimal for CR
ch=getch())!=015 // octal for CR