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
Ask question #write statement that assign random integer to the varaible n in the (100

what happens when the following command is used? chmod u=rwx,go=r-x foo

Write a Program to illustrate the Call by Reference? Here is an illustration: #include . int compute_sum(int *n); int main( void) { int n=3, sum; printf("%d\n",n); /

Need Payment Gateway Integration Expert Project Description: I am seeking for expert payment gateway integration. You must have done or have experience with integrating me

Write a C program to input five numbers and print them out on a new line e.g 5, 10, 15, 20, 25 displayed as   5   10   15   20   25 #include stdio.h   void main()   {

Your task in this project is to write a C program named layout.c which does text layout. This is a staged project, complete the stages in order. The maximum mark if you nish each

Molecular dynamics for a Lennard-Jones system (in C++) 1. Write a function which reads in the input variables of a molecular dynamics simulation of a Lennard-Jones system. The inpu

B-tree: A B-tree is an also called balanced m-way tree. A node of the tree may have many records or key and pointers to children. It is also called as the balanced sort tree. It s

#solution for decode the code for smuglers

Reference Oddities A reference variable can demote to any integer variable, be it in an array or a member variable from structure or class. Reference variables can demote to co