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
find the c program to find area under the curvey=f(x)   #include float start_point, /* GLOBAL VARIABLES */ end_point, total_area;

can you tell me what is c#

For this program, you are going to modify your previous program (program 3) so that it will now have a menu to see if the user wants to read the input from a file or interactively.

Rahul is a newbie to the programming and while learning the programming language he came to know the following rules: · Each program must start with ''{'' and end with '

Read numbers form user and place them in array: Program is to read a group numbers of numbers form user and place them in array type of float and sort them void sort(floa

color representation 0,1,2,3,4,5,6,7...

Define One's Complement Operator? The one's complement operator, occasionally called the "bitwise NOT" or "bitwise complement" operator produces the bitwise one's complement of

Write a function that takes in a number n and divides the screen into n vertical bars, alternating black and white. (What should you do if someone puts in n=0 or n=-99?)

There are ''n'' ants on a ''n+1'' length rod. The ants are numbered from 1 to n and are initially placed at positions starting from position 1 till position n. They are moving eith

A: No. If they're utilized properly, they increase encapsulation. You frequently require splitting a class in half while the two halves will have distinct numbers of instances o