[go: up one dir, main page]

0% found this document useful (0 votes)
43 views1 page

Program 3: Count Number of Alphabets and Digits in A Text File

This C++ program counts the number of alphabets and digits in a text file. It uses functions like isalpha and isdigit to check each character read from the file and increment the corresponding count variable. Once the entire file is read, it displays the number of alphabets and digits found in the file.

Uploaded by

Tanishq Kapoor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views1 page

Program 3: Count Number of Alphabets and Digits in A Text File

This C++ program counts the number of alphabets and digits in a text file. It uses functions like isalpha and isdigit to check each character read from the file and increment the corresponding count variable. Once the entire file is read, it displays the number of alphabets and digits found in the file.

Uploaded by

Tanishq Kapoor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

PROGRAM 3

Program to Count number of alphabets and digits in a


text file
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<ctype.h>
void main()
{
clrscr();
char ch;
int count=0;
int count1=0;
ifstream fil("honey.txt");
while(!fil.eof())
{
fil.get(ch);
if(isalpha(ch))
{
count++;
}
else if(isdigit(ch))
{
count1++;
}
}
cout<<"number of alphabets are : "<<count<<endl;
cout<<"number of digits are : "<<count1<<endl;
fil.close();
getch();
}

Text file contents


1234 by

You might also like