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
C Program for FUNCTION OF COPY ONE STRING IN OTHER STRING #include stdio.h> #include conio.h> int copy(char a[],char b[]); void main() {           char a[100],b[

Question 1 Explain the concept of constructors and destructors in C++ with programming examples Question 2 Explain the concepts and applications of multiple inheritance and v

Ask quIn the Byteland country a string "s" is said to super ascii string if and only if count of each charecter in the string is equal to its ascci value in the byteland country as

Write a Program for Calculating Value of an Integer? For a clear understanding of recursive function we shall see an illustration for calculating value of an integer. main() {

Aim: To implement program to calculate area of cube using inline function. Code: inline void area_cube(float side) {             float area;             are

Define the Stream Oriented Data Files? There are two dissimilar types of data files called stream-oriented (or standard) data files and system-oriented (or low-level) data file

Q-What happens while a function throws an exception which was not specified through an exception specification for this function? A: Unexpected() is called, which, by default, w

Write a program to act as an electronic safe. If the correct code has been entered the program should display "Safe Open".  If an incorrect code is input it should display "Alarm"

#questioA 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 str

I can''t figure out how to stop the programming from hitting for the player even when they type in stand.