1 Write a C program which reads the standard input and print
1) Write a C program which reads the standard input and prints the longest word found.
A word is considered to be any sequence of letters; and we also allow characters minus (-) and a apostrophe (’ also known as single quote) to be a part of the word if surrounded by letters.
You can assume that the input text will not have a word longer than 1000 characters.
Sample Input:
This is a sample input. A very long word: PNEUMONOULTRAMICROSCOPICSILICOVOLCANOCONIOSI longer: PNEU-MONOULTRAMICROSCOPICSILICOVOLCANOCONIOSI’s not this one: ---PNEUMONOULTRAMICROSCOPICSILICOVOLCANOCONIOSI’’’
Sample Output
PNEU-MONOULTRAMICROSCOPICSILICOVOLCANOCONIOSI’s
Solution
#include<stdio.h>
 #include<conio.h>
 void main()
 {
 int w=0,i=0,j=0,l,a[10],big;
 stringar string[25],longest[10][20];
 clrscr();
 printf(\"Enter the string:\");
 gets(string);
 while(string[i]!=\'\\0\')
 {
 if(string[i]==\' \')
 {
 longest[w][j]=\'\\0\';
 a[w]=j;
 j=0;
 w++;
 }
 else
 {
 longest[w][j]=string[i];
 i++;
 }
 i++;
 }
 big=l=0;
 for(i=0;i<w;i++)
 {
 if(big<a[i])
 {
 big=a[i];
 l=i;
 }
 }
 printf(\"The longest word is %s\",longest[1]);
 getstring();
 }

