Program to accept a string print each word in new line - 100 Most Important C# Programs

100 Most Important C# Programs

31. Program to accept a string print each word in new line.

Code:

# include <stdio.h>

# include <conio.h>

main( )

{

char ch;

clrscr( );

printf(“enter a string :”);

while(( ch=getchar( ))!=’\n’)

{

putchar(ch);

if(ch= =’ ‘)

printf(“\n”);

}

getch( );

}