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
what is a string?

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

Specifying a Class: As discussed a class is defined to develop an algorithm and bind it together in a core shell. A class is an abstract data type (ADT).  The binding of dat

removing jewel from a necklace

C Program for 5 FUNCTION OF VOWELS, CNT_WORDS, REVERSE void input(char a[]); void output(char a[]); void reverse(char a[], char b[]); char poli(char a[], char b[]);


#include #include #include using namespace std; #define MAX 5 #define INF (1 #define DEBUG if(0) #define pii pair #define pb(x) push_back(x) class

WAP TO ACCEPT MARKS OF THREE SUBJECT FOR STUDENT & CALCULATE TOTAL MARKS AND PERCENTAGE #include stdio.h> #include conio.h>   void main() {            int M1,M

Problem Write a program in C++ to read N numbers in an array, the user should be able to search a particular number in the array using sequential search algorithm. Writing a