Friday, 7 December 2012

String length cpp program

CPP program to find length of  a string

#include<iostream.h>
#include<conio.h>
class length
{         char str[100];
   public:
          void find();
};
void length::find()
{        int i=0;
          cout<<" Enter a String : ";
          cin>>str;
          while(str[i]!='\0')

          {        i++;}
          cout<<" String contains "<<i<<" letters";
}
void main()
{        clrscr();
          length l;
          l.find();
          getch();
}

No comments:

Post a Comment