C program for function of count the characters in each word, C/C++ Programming

C Program for FUNCTION OF COUNT THE CHARACTERS IN EACH WORD

void count(char c[]);

void main()

{

          char a[50];

          int i=0;

          clrscr();

          printf("ENTER THE STRING: ");

          do

          {

                   a[i++]=getchar();

          }while(a[i-1]!='\n');

 

          a[i]='\0';

          count(a);

          getch();

}

void count(char a[])

{

          int i=0,l[25],c=0;

          for(i=0;i<25;i++)

                   l[i]=0;

          for(i=0;a[i]!='\0';i++)

          {

                   if(a[i]!=' ' && a[i]!='\n')

                             l[c]=l[c]+1;

                   else

                             c++;

          }

          for(i=0;l[i]!=0;i++)

                   printf("WORD : %d : %d\n",i+1,l[i]);

}

 

OUTPUT :

ENTER THE STRING: KAMLESH D MENGAR

 

WORD 1 : 7

WORD 2 : 1

WORD 3 : 6

Posted Date: 9/10/2012 7:50:36 AM | Location : United States







Related Discussions:- C program for function of count the characters in each word, Assignment Help, Ask Question on C program for function of count the characters in each word, Get Answer, Expert's Help, C program for function of count the characters in each word Discussions

Write discussion on C program for function of count the characters in each word
Your posts are moderated
Related Questions
C program to print fibonacci series: int fibo(long int); void main() {                 long int a=0,n;                 printf ("how many terms\n");

Overloading a method (or function) in C++ is the ability for functions of the similar name to be defined as long as these methods have dissimilar signatures (different set of param

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

t a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with these

Write a program to count the prime number in array

question c

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.

Ravi is a newbie to the programming and while learning the programming language he came to know the following rules: · Each program must start with ''''''''{'''''''' and end wi

I need to program a microprocessor that would have a temperature, gas, humidity and PIR sensor connected to it. It would send the data to a PC via a Zigbee and receive commands fro

I need a client-server architecture program for windows OS (minimum support: Win 7),. the agent program will run as a background process and perform certain tasks every X time, and