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

Assignment Help:

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);

         }


Related Discussions:- C program to count the words

Arrays within a class, A r r a y s w i t h i n a c l a s s:...

A r r a y s w i t h i n a c l a s s: I t i s j u s t d ecl a r i n g o r c on s t ru c ti n g a d e r i v e d t

Explain mixed mode expressions and implicit type conversions, Mixed Mode Ex...

Mixed Mode Expressions and Implicit type Conversions A mixed mode expression is one in which the operands are not of the similar type. In this case, the operands are converted

program to conduct timber structural component design, The question descri...

The question description: You are required to make a C++ program to conduct timber component (beam and column) structural design according to EC5 (all the relevant design codes

The Polishing Game, Byteland county is very famous for luminous jewels. Lum...

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

Define some features of automatic variables in c program, Define Some Featu...

Define Some Features of Automatic Variables in C program? The features of automatic variables are like as Storage - memory Default initial value - an unpredictable value,

Oop, evolutio of object oriented programing

evolutio of object oriented programing

Padovan string, A Padovan string P(n) for a natural number n is defined as:...

A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a string of t

C++, padovan string c++ program

padovan string c++ program

Area under curve, Write a program to find the area under the curve y = f(x)...

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. The area under a curve betw

OpenGL configured environment, 1. Using Visual C++ and your OpenGL co...

1. Using Visual C++ and your OpenGL configured environment, write an application that displays a “unique” graphical scene that you designed and coded for this course. What yo

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd