Write a program that opens a text file and reads its contents into a queue of characters. The program should then dequeue each character and have a counter to see how many of the characters are actually letters. This number should be printed to the console for the user

Respuesta :

Answer:

Please see explaination for code and attachment for output

Explanation:

The program source code.

#include <iostream>

#include <fstream>

using namespace std;

int main()

{

ifstream fs("xy.txt");

char ch;

string str=""; // for storing characters

while(fs>>ch)

{

str=str+ch; // appending characters to string

}

int i=0,count=0;

while(str[i]!='\0')

{

if((str[i]>=65 && str[i]<=90)||(str[i]>=97 && str[i]<=122))

{

count++;

}

i++;

}

cout<<"No. of Alphabets:"<<count<<endl;

}

xy.txt:

Check attachment for output and code on screen.

Ver imagen kendrich
Ver imagen kendrich