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
Explain one-definition rule (ODR). According to one-definition rule, C++ constructs should be identically defined in each compilation unit they are used in. As per ODR, two

Question 1 Implement a class stack which simulates the operations of the stack allowing LIFO operations. Also implement push and pop operations for the stack 2 Explain the c

2 flowcharts, pseudocode for each (at least 4 algorithms), and code for either a stack or a queuestion..

example of program to ad two numbers

finds the average for all assignments for an individual student float getAverageForStudent(float scores[20][10], int student, int numAssignments) {  }  // finds the average for

A container class is a class which is used to hold objects in external storage and memory. A container class work as a generic holder. A container class contains a predefined behav


Writing and compiling a program from a given Use Case definition. Follow the Average Temperature in Paradise

Demonstration using Moss Open Source Machine Translation Project Description: Moses is an open source Statistical Machine Translation System. I need someone to provide me a d

Which one would you prefer - a macro or a function? Actually it depends on the purpose of program! - In case of macros, corresponding code is inserted directly into your sou