C++ Program to Count no. of alphabates,digits and spaces present in a file STORY.TXT

C++ Program to Count no. of alphabates,digits and spaces present in a file STORY.TXT

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

void main()
{
clrscr();
ifstream  fin(“STORY.TXT”);
char ch;
int i,a=0,s=0,d=0;

while(fin)
{
fin.get(ch);
i=ch;
if(i>63&&i<91||i>96&&i<123)
a++;
else
if(ch==’ ‘)
s++;
else
if(i>47&&i<58)
d++;
}
cout<<“No. OF Alphabates:”<<a;
cout<<“nNo. Of Digits:”<<d;
cout<<“nNo. Of Spaces:”<<s;
getch();
}

9 thoughts on “C++ Program to Count no. of alphabates,digits and spaces present in a file STORY.TXT

  1. meenu

    if a person does not have anything in the file then what should he do to perform any function on that text file.

    Reply
    1. Neeraj Mishra

      @meenu it is necessary to insert something in the file before performing any function on that text file…….

      Reply
      1. ammu

        how to do dat ??does dat mean we have to make a another ofstream function for dis??

        Reply
  2. Michael Scott

    What does this mean/do? Cannot find any information on it.

    if(i>63&&i96&&i<123)

    Reply
  3. abhishek

    I WANT THIS QUES ANS PLS……. SEND ME IN MAIL(2001abhishekp@gmail.com)
    Write a program to input the name of a text file from the user and display:
    a) The number of blanks present in the file.
    b) The number of lines present in the file.
    c) The number of capital alphabets present in the file.
    d) The number of small alphabets present in the file.
    e) The number of lines starting with a capital alphabet.
    f) The number of words present in the file.
    g) The number of digits present in the file.
    h) The number of words ending with a vowel

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.