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
What program is considered the industry standard for digital graphics and image editing?
denpristay [2]
I believe photoshop, or illustrator
7 0
3 years ago
Read 2 more answers
Go follow me plz i would appreciate it
aleksandr82 [10.1K]
Hejdjxuxudjjdjdbdbdbd
6 0
3 years ago
Read 2 more answers
Finish the sentence. If the IP address and MAC address are parameters of layer 3 and layer 2, respectively, a port number is a p
stepan [7]

Answer:

Layer 4

Explanation:

MAC address works at the data link layer (layer 2) of the OSI model. Mac address allows computers to uniquely identify themselves in the network

IP Address is a logical address that works at the network layer of OSI model (layer 3) (actually the IP layer of TCP/IP model).

The port number works at the transport layer of the OSI model (layer 4).The port number uses sequence number to send segments to the correct application thereby ensuring they arrive in the correct order.

7 0
3 years ago
Select one or more of the following: Which of these events will cause signal(s) to be generated by the kernel (the operating sys
nikitadnepr [17]

Answer:

a. The process has done something wrong (segmentation fault, etc.)

Explanation:

Events that cause signals to be generated by kernel and sent to childless foreground process is the process has done something wrong(segmentation fault), as Hardware exceptions generate signals,for example, divide by 0 or invalid memory reference. These conditions are usually detected by the hardware, and the kernel is notified. The kernel then generates the appropriate signal for the process that was running at the time the condition occurred.

7 0
3 years ago
A diet to contain at least 2400 units of vitamins, 1800 units of minerals, and 1200 calories two foods , Food A and Food B are t
Firdavs [7]

Answer:

30 units of Food A and 45 units of Food B are to be purchased to keep costs at the minimum $105.

Explanation:

X = Amount of food A

Y = Amount of food B

Z= 2X+Y..... minimum cost equation

50X + 20Y > 2400 .................Vitamins .......(1)

30X + 20Y > 1800 ...................Minerals.......(2)

10X + 40Y > 1200 .................Calories ..........(3)

X  > 0

y  > 0

X=30  and Y = 45

Z= 2(30) + 45 = $105

8 0
3 years ago
Other questions:
  • Power point 2016 which chart element provides the boundaries of the graphic?
    6·1 answer
  • does someone know how to change G,o,o,g,l,e and utube location or choose what ads I wanna see, the ads and info that pops out on
    6·1 answer
  • Which of the following statements is TRUE?
    11·2 answers
  • Which are valid double statements for java? double a = 0; double b = -1.0; double c = -425; double d = 6340; double e = -1.0; do
    12·2 answers
  • Consider five wireless stations, A, B, C, D, and E.
    13·1 answer
  • _____ is a software delivery approach in which an organization outsources the equipment used to support its data processing oper
    5·1 answer
  • Which element is included in the shot breakdown storyboard? Which element is included in the shot breakdown storyboard?
    8·1 answer
  • Write a program that accepts an integer value called multiplier as user input. Create an array of integers with ARRAY_SIZE eleme
    7·1 answer
  • Heeeeeeeelp :)<br> thx<br> jfdyiusjmkdsuiho;dmcvrvho;j
    5·2 answers
  • scheduling is approximated by predicting the next CPU burst with an exponential average of the measured lengths of previous CPU
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!