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
Define a class? A: It is an expanded concept of a data structure: rather than holding only data, it can hold data and functions both.

c program to implement least cost method

Write a C++ program which does the following: 1. Asks the user to enter the following text "Four score and seven years ago there was a man named Joey Bagadonuts." 2. Save thi

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.

Assume that a Binary Search Tree is constructed by repeatedly inserting exact values in to the tree. Argue that the number of nodes examined in searching for a value in the tree is

how to create the programs in c++ knowledge

Asks the user for an integer. if the number is less than 21, ask them for a number again; repeat this until you get a number bigger than 20. 20 is not an acceptable number. Once yo

Create Complex number using constructor: class complex                                 {                                                   private:


Q: however shouldn't I always use a printOn() method instead of a friend function? A: No. The usual cause people wish to always use a printOn() method instead of  a friend fu