C program count characters words with space & without space , C/C++ Programming

void main()

{

          int i,j,len=0,word=1,lens=0,ll=1;

          char str[100];

          clrscr();

          printf("ENTER THE STRING: ");

          gets(str);

          for(i=0;str[i]!='\0';i++)

          {

              len++;

                   if(str[i]==' ')

                          word++;

                   else

                         lens++;

          }

          printf("CHARACTERS WITH SPACE : %d\n",len);

          printf("CHARACTERS WITHOUT SPACE : %d",lens);

          printf("\n                    WORDS : %d",word);

          getch();

}


OUTPUT :

ENTER THE STRING: KAMLESH MENGAR

       CHARACTERS WITH SPACE : 14

CHARACTERS WITHOUT SPACE : 13

                                          WORDS : 2


Posted Date: 9/10/2012 3:01:43 AM | Location : United States







Related Discussions:- C program count characters words with space & without space , Assignment Help, Ask Question on C program count characters words with space & without space , Get Answer, Expert's Help, C program count characters words with space & without space Discussions

Write discussion on C program count characters words with space & without space
Your posts are moderated
Related Questions
Develop a C++ program that uses a while to determine the gross pay (in Dollars) for each of several employees. The company pays “straight-time” for the first 40 hours worked by ea

The Switch Construct The switch statement is a multi-way decision-making construct that tests an expression matches one of a number of constant values, and branches accordingly

How much does it cost to complete a C++ assignment that is 80% finished??

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 between two points can b

a) Define an Asset base class that provides the following method: class Asset { public:      virtual double getValue()=0; };   This will be the base class for both stock an

a program to find the area under curve y=f(x) between x=a and x=b,integrate y=f(x) between the limits of a and b.   #include float start_point, /* G

C Program to FIND VOWELS AND REMOVE VOWELS void main() {           char s[100],s1[100];           int i,j,k=0;           clrscr();           printf("ENTER ANY S

C o n t r o l S t r u c t u r e s I t i s o f t h r e e t y p e s: 1 .    S e qu e n c e s t r u c t u r e 2 .

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

// Basic pointer code #include "stdafx.h" #include iostream using namespace std; int _tmain(int argc, _TCHAR* argv[]) {             int FirstNumber, SecondNumber;