Make Your Search Easy ! :) Use me

Friday, February 17, 2017

To count number of vowels in a file :-

#include<iostream>
#include<conio.h>
#include<fstream.h>
#include<ctype.h>

void main()
 {
  ifstream fin("story.txt");
  char c;
  int count1=0;
  while(fin)
     {
    fin.get(c);
    if(isupper(c))
             {
                c=toupper(c);
               }
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
             {
      count1++;
               }
         }
  fin.close();
  cout<<" \nnumber of vowels is     :"<<count1<<endl;
  getch();
 }

No comments:

Post a Comment