Encoders
  Home  Forum  Guestbook  Email Us  About Us  Links  More Hub for Computer Whizzes Register to join us

C
C++
Security
Miscellaneous
Encoders > More... > C > Program 6

<< Previous  Next >>


/* Program to print a histogram of the lengths of words in its
input. */

#include <stdio.h>

#define IN	1
#define OUT	0

main()
{
	int c, state=OUT,i=0;

	while(c=getchar())
		if(c!=' '&&c!='\t'&&c!='\n'&&c!=EOF)
		{
			state=IN;
			putchar(c);
			i++;
		}
		else if(state==IN)
		{
			state=OUT;
			printf("\t\t");
			for(;i>0;i--)
				putchar(178);
			printf("\n");
			if(c==EOF)
				break;
		}
	printf("\n");
}

 

encoders.20m.com - hosted at 20m.com
Site design and development by Susam Pal
-----------------------------------------------------