PROGRAM TO CALCULATE NUMBER OF WORD AND DIGITS IN THE FILE

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<ctype.h>
#include<fstream.h>
void c_alpha()
{ ifstream in;
  int x,y,c=0,d=0;
  char ch;
  in.open("abc.txt");
  if(!in)
  { cout<<"file not found:";
    exit(0);
   }
   while(!in.eof())
   { in>>ch;
     x=isalpha(ch);
     if(x==1)
     c++;
     y=isdigit(ch);
     if(y==1)
     d++; 
  }
    in.close();
    cout<<"no. of alphabets :"<<c;
    cout<<"no. of digits are :"<<d;
  }
  void main()
  { clrscr();
    c_alpha();
    getch();
   }

Comments

Popular Posts