0% found this document useful (0 votes)
40 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)
40 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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy