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
Refactoring Project Description: TASK 1 - DESIGN ALGORITHM You are required to design a suitable solution algorithm by using structured chart, pseudocode or flowchart. Thi

When I develop a destructor, do I require to explicitly call the destructors for my member objects?

Can you overload a function depend only on whether a parameter is a value or a reference? A: No. Passing by value and reference looks identical to the caller.

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

how to write a c program for stone game


A 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 string of t

What does throw; (with no exception object after the throw keyword) mean? Where would I employ it? A: You should see code that looks something like this: class MyException

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

Define  T y pe c o m p a t i b i li t y? T o a s s i g n i n t t o s m a l l i n t t h e v a r i a b l e should b e