C program to count the words, C/C++ Programming

C program to count the words:

void CountWords();

         void main()

         {

            printf("\n\tcount the words and enter string\n\n\n");

            CountWords();

 

         }

        void CountWords()

        {

            char c;

            int num=0;

            int flag= 0;

             while((c=getchar())!='\n')

            {

                                                if((c==' ')||(c=='               ')||(c=='.')||(c==';')||(c==',')||(c==';')

                                                                ||(c==':')||(c=='"')||(c=='?')||(c=='!')||(c=='-'))

              {

                flag=0 ;       

              }                         

              else if(flag==0)

              {

                num++;

                flag=1;    

              }

 

           }

              printf("\t\n\n\nNumber of words is %d\n",num);

         }

Posted Date: 9/29/2012 7:12:05 AM | Location : United States







Related Discussions:- C program to count the words, Assignment Help, Ask Question on C program to count the words, Get Answer, Expert's Help, C program to count the words Discussions

Write discussion on C program to count the words
Your posts are moderated
Related Questions
Prepare a script for providing Instagram Followers/Likes I need to prepare a panel where my customer able to get Instagram followers or likes automatically. - A panel where I

write a class player that contain attributes for the player,s name,average and team

1 Aims The main purpose of the assignment is to let you practice the following programming techniques: perform operations on pointers to basic and more complex types;

Mathematical Statements and assignments    Within C we can directly load up the variable from within the program using the mathematical expression equates (=) e.g.   a= 'h'

Need help in network programming in C++ project. How much you charge?

Define the Float Data Type of c Language? The float is used to define floating point numbers. The Floating point numbers are stored in 32 bits with 6 digits of precision. Eg

where to use tower of honoi?

Generate a class node that contains an integer id, a position (x, y)  and a vector of 0 5,  generate a set of  x nodes each with random connectivity n.    Implement an algorith

overload assignment opertor to assign the data of one object to anthor

world wide web commands