Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

Friday, July 26, 2013

Program to reversing a string

#include<iostream.h>
#include<conio.h>
#include<string.h>
void main()
{
char name[20],rev[20];
int len,k=0;
cout<<"Enter the string  ";
cin.getline(name,20);
for(len=0;name[len]!='\0';len++)
for(i=len;i>=0;i--)
{
rev[k]=name[i];
k++;
}
rev[k]='\0';
cout<<"Reversed string  ";
cout.write(rev,20);
getch();
}

Wednesday, July 24, 2013

Program to count the number of lower case vowels in a string


#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
void main()
{
 clrscr();
 char st[100];
 int l,n,i;
 cout<<"Enter the string\n";
 cin.getline(st,100);
 l=strlen(st);
 for(i=0;i<=l;i++)
 {
   if(islower(st(i))) && ((st(i)==a)||(st(i)==e)||(st(i)==i)||(st(i)==o)||(st(i)==u))
   n++;
 }
 cout<<"The number of lower case vowels is : "<<n;
 getch();
}

Monday, July 22, 2013

Program to find whether two strings contain equal number of characters

#include<iostream.h>
#include<conio.h>
#include<string.h>
int main()
{
char s1[60],s2[60];
cout<<"Enter strings ";
cin.getline(s1,60);
cin.getline(s2,60);
if((strlen(s1))==(strlen(s2)))
cout<<"Both strings contain equal number of characters ";
else
cout<<"Both strings contain different number of characters ";
return0;
}