Friday, 15 September 2017

12th C Program 8 : Counting number of vowels


#include<fstream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
 clrscr();
 char str[50],ch;
 int no=0;
 ofstream fo("string.txt");
 cout<<"\n Enter a String:";
 gets(str);
 fo<<str;
 fo.close();
 ifstream fi("string.txt");
 cout<<"\n String Enter is";
 while(fi)
{
 fi.get(ch);
 cout<<ch;
 switch(ch)
{
 case'a':
 case'A':
 case'e':
 case'E':
 case'i':
 case'I':
 case'o':
 case'O':
 case'u':
 case'U':
 no++;
}
}
fi.close();
cout<<"\n No of Vowels :"<<no;
getch();
}

No comments:

Post a Comment