Mar 5, 2007

C++ Program to count vowels in given string

C++ program to count vowels in a string. This program will ask user to input a string of maximum 40 characters and then it will count vowels in the given string.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
main()
{
int i;
clrscr();
char st[40];
cout<<"Enter Any String Maximum 40 Characters";
gets(st);
i=0;
for (int k=0;st[k]!='\0';k++)
{
if(st[k]=='a' st[k]=='A' st[k]=='e'
st[k]=='E' st[k]=='i' st[k]=='I'
st[k]=='o' st[k]=='O'st[k]=='u'
st[k]=='U')
i++;
}
cout<<endl<<"The of Vowels in this string is = "<<i;
getch();
}

No comments:

Post a Comment

Infolinks In Text Ads

Total Pageviews

Powered by Blogger.

Dont Forget To Follow Us

Blog Archive