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 to FIND THE EVEN WORDS IN THE STRING #include conio.h> #include stdio.h> void main() {           char a[50],temp;           int i=0,k=0,l[25],c=0,r=0;

Car Rental System This system tracks cars in a rental company. Each car has a number (assume its plate number), type (small car, four wheel car), and status (rented, available). T

write a C++ program that performs the following tasks 1. prompts the user to enter two numbers 2. displays the divisors of each number and store the divisors of number 1 in A and t

Rule: To determine the canonical form we should OR the min terms. A min term is defined as a Boolean equation of the input if the output is logic '1'. If the input is logic '1'

Return by reference: The return value of the function must be an address variable.  In following program the function returns the value of x or y and their types are declare

Program to convert fraction to decimal: int main() {                 float num, denom;     // numerator and denominator of fraction                 float value;

Scope Rules and Storage Classes The storage class verifies the life of a variable in terms of its duration or its scope. There are four storage classes : automatic static


Part 1 Assignment:  develop a calculator in MASM. Text chapters covered:  1 through 4, 5.4, 5.5, 6.3, 7.4 You will develop a "calculator" algorithm in MASM using reverse-

c program to implement least cost method