Thursday 7 May 2015

COUNT LOWERCASE ALPHABET IN A FILE

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<ctype.h>
#include<process.h>
void main()
{clrscr();
ifstream fin;
char filename[12];
cout<<"HIMANSHU SINGH \n";
cout<<"Enter file name\n ";
cin.getline(filename,12);
 fin.open(filename,ios::in);
 if(!fin)
 {
cout<<"\n file not found ";
 exit(-1);
 }
char ch;
int count=0;
while(!fin.eof())
{ fin.get(ch);
 if(islower(ch))
    count++;
}
fin.close();
cout<<"total lowercase alphabets are= "<<count<<"-- HIMANSHU SINGH";
getch();
}

selected file for opening is LOWER.TXT
OUTPUT

No comments:

Post a Comment