Answer to Question #309455 in C++ for nickname

Question #309455

This program will write a series of letters, starting with 'A', to an external file (letters.txt). The user will decide how many letters in total get saved to the file.

 

** IMPORTANT: The test cases will evaluate your code against .txt files that I uploaded. You do NOT have to upload your own txt files.

 

Input:

Including 'A', how many total letters would you like to store?   [user types: 26]

 

Output (in the file, not in the console window)

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z


1
Expert's answer
2022-03-11T07:23:39-0500
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main()
{
	int count;
	cout << "Including 'A', how many total letters would you like to store ?: ";
	cin>> count;
	ofstream of;
	of.open("letters.txt");
	if (!of.is_open())
		cout << "File isn`t opened!";
	else
	{
		for (int i = 0; i < count; i++)
		{
			of << char(65 + i) << " ";
		}
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment