C program to find the even words in the string, C/C++ Programming

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;

 

          clrscr();

          for(i=0;i<25;i++)

          {

                   l[i]=0;

          }

          i=0;

          printf("ENTER THE STRING: ");

          do

          {

                   a[i++]=getchar();

          }while(a[i-1]!='\n');

          a[i]='\0';

          printf("%s",a);

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

          {

                   if(a[i]==' ' || a[i]=='\n')

                   {

                             temp=a[k];

                             a[k]=a[i-1];

                             a[i-1]=temp;

 

k=i+1;

                             c++;

                   }

                   else

                   {

                             l[c]++;

                   }

          }

          for(i=0;l[i]!=0;i++)

          {

                   if(l[i]%2==0)

                   {

                    r++;

                   }

          }

          printf("%s\n",a);

          printf("THE TOTAL NO OF EVEN WORDS ARE:  %d",r);

          getch();

}

OUTPUT :

ENTER THE STRING: KAMLESH D MENGAR

HSELMAK D RAGNEM

THE EVEN WORDS ARE : 1

 

 

Posted Date: 9/10/2012 7:21:01 AM | Location : United States







Related Discussions:- C program to find the even words in the string, Assignment Help, Ask Question on C program to find the even words in the string, Get Answer, Expert's Help, C program to find the even words in the string Discussions

Write discussion on C program to find the even words in the string
Your posts are moderated
Related Questions
Question: a) Give two uses of NFS. b) Give one advantage of using NFS. c) Explain the following lines as they would be interpreted in the /etc/exports file i. /usr/local

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

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

how do i write a c++ program that will input a number and output its factorial using the while loop

Ask question #Minimum 100 words acceptedEducational Objectives: After completing this assignment, the student should be able to accomplish the following: Apply generic algorithms i



algorithm to find out all the factors of given positive integers

Program is to read the characters from keyboard: Program is to read the characters from keyboard one by one stored in different files as upper constants, lower constants, othe

#question.Write a c++ program to accept and print a 1_d array