1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
marshall27 [118]
3 years ago
15

Write a function that reads a text file, which has been opened in main program, and RETURNS the number of alphabetic characters

(isalpha), digits (isdigit), punctuation characters (ispunct), and whitespace characters (isspace) in the file.
Here isalpha, isdigit, inpunct and isspace are C++ standard library functions, which are included in header file. More details about these functions are provided in Chapter 10.
Demonstrate the function in a complete program.
Hint
Use get function to read data from the file. For example, if fsIn is an opened input stream, then the following statement reads a character to the variable aChar from the opened file:
fsIn.get(aChar);
To read all data from a file, use while loop as follows:
while (fsIn.get(aChar)) // this is similar to while (fsin >> aChar)
{
……
}
Computers and Technology
1 answer:
Greeley [361]3 years ago
5 0

Answer:

See Explaination

Explanation:

Code below

#include<fstream>

#include<conio.h>

#include<iostream> //libraries required

using namespace std;

int main(){

ifstream fin("input.txt"); //reading the file from the computer

char character;

int alphabets=0;

int spaces=0,digits=0,pucntuations=0; //initializing the variables

while(fin){ //looping all the characters in the file

fin.get(character); //getting the character one at a time

if(isalpha(character)) // if the character is alphaber we increment the alphabet variable

alphabets++;

else if(character==' ') // if space

spaces++;

else if(isdigit(character)) // if digit

digits++;

else if(ispunct(character)) // if punctuation

pucntuations++;

}

cout<<"Number of Digits:"<<digits<<endl; //priting out the results

cout<<"Number of Spaces:"<<spaces<<endl;

cout<<"Number of Alphabets:"<<alphabets<<endl;

cout<<"Number of Pucntuations : "<<pucntuations<<endl;

return 0;

}

You might be interested in
PLEASE HELP SOMEONE!!!!!!!!! WILL GIVE BRAINLIEST!!!!!!!!!!!!!!!!!!!!!!!!! Fill in the blanks.
olasank [31]
<span> change the behavior of the program I think</span>
7 0
4 years ago
Aaron is stating the main idea of what he read in his own words. He is _____.
Feliz [49]

Answer:

summarizing

Explanation:

when someone explains in their own words the main idea of a story, it is summarizing.

8 0
3 years ago
Read 2 more answers
Which programming language uses objects?<br> O C++<br> O ALGOL<br> O Pascal<br> O BASIC
AfilCa [17]

Answer:

Both C++ and Pascal uses objects.

5 0
4 years ago
Read 2 more answers
Select the correct answer from each drop-down menu. Kristian is a cybersecurity professional. She is writing a book called The D
Papessa [141]

Data sharing, maintaining security

<u>Explanation:</u>

Kristian is a cybersecurity professional. She is writing a book called The Door Toward Cybersecurity. Organizations should avoid any data <u>sharing or exchange</u> while servers are transmitting information. This will help organizations keep the information intact and maintain <u>security.</u> If any info or data shared when the servers are transmitting the info, then it may lead to the loss of security, and the information gets leaked. So it must be avoided to share while transmission of info using the servers.

3 0
3 years ago
Read 2 more answers
Please read !!!
prisoha [69]
Don’t stress. You’re no failure if you believe in yourself. Have some faith. Don’t give up and live your life to the fullest. Take care and stay safe!! :)
3 0
3 years ago
Other questions:
  • Rebecca received the following e-mail from her boss: I NEED ALL EMPLOYEES TO WORK LATE ON SATURDAY. NO EXCEPTIONS! What is the m
    13·2 answers
  • Blogs are typically written by large companies or organizations as a way to express formal, technical, or scholarly information
    5·2 answers
  • A virtual private network (VPN) is used to securely connect to another network over a insecure network.
    9·2 answers
  • i set up an account and paid the yearly fee, now it's asking me to join. i've tried to log in and brainly isn't accepting my ema
    8·1 answer
  • Please hurry Arrange the steps of the engineering design process in the correct sequence.
    10·1 answer
  • Answer the queston...........​
    7·2 answers
  • List the operating system you recommend, and write a sentence explaining why.
    8·1 answer
  • Why does my roku tv keep disconnecting from the internet.
    13·1 answer
  • ______________ are used to store information that will be referenced and manipulated in a computer program. They label data with
    6·1 answer
  • What is one way object-oriented programming differs from procedural programming?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!