Friday, 14 September 2012

C++ Program to input any string and print the number of 'the'

C++ Program to input any string and print the number of 'the'

 #include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
main()
{
clrscr();
char name[50];
int l=0,c=0;
cout<<"Enter any string "<<endl;
gets(name);
l = strlen(name);
cout<<endl;
for(int i=0;i<=l;i++)
{
if ((name[i]=='t') && (name[i+1]=='h') && ((name[i+2])=='e'))
c=c+1;}
cout<<endl;
cout<<"total the is "<<c;
getch();
return 0;

}

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More