/* Vertical Histogram of Words in a Sentence */
#include<stdio.h>
#define MAXWL 20 /* Maximum length of a Word */
#define MAXNO 25 /* Maximum No of Words in a sentence */
int main(void)
{
int Word[MAXNO];
int i,c,j,nc,nw;
for(i=0;i<MAXNO;++i)
Word[i]=0;
nc = nw = 0;
while( (c=getchar()) != EOF)
{
++nc;
if( c ==' ' c =='
' c ==' ')
{
Word[nw] = nc -1; /* -1 for excluding the space in the Word length */
++nw;
nc = 0; /* resetting the Word-length for the next Word */
}
}
for( i = MAXWL; i >= 1; --i)
{
for(j=0;j <= nw;++j)
{
if( i <= Word[j])
putchar('*');
else
putchar(' ');
}
putchar('
');
}
return 0;
}
Copyright © 2026 eLLeNow.com All Rights Reserved.