.txt files...how to read/open them?

I need to open these quiz questions from a .txt file.

I created a file by Right click , New, .txt file, paste it, and how can I open this file on the console window? Do I need to do any extra step to create a file that I want to open?

Thanks in advance.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;

int main()

{
	cout << "Hello and good luck taking this quiz." << endl;
	"\n";
	int choice, score = 0;
	string name;
	double score1;


	cout << "Please enter your full name." << endl;
	getline(cin, name);

	cout << "Which of the following is a datatype?" << endl;
	cout << "1. int " << endl;
	cout << "2. doubletriple" << endl;
	cout << "3. setdecimal" << endl;
	cout << "4. Valuemore" << endl;
	cout << "\n" << endl;
	cin >> choice;

	if (choice != 1)
	{
		cout << "Sorry, you are incorrect." << endl;
	}
	else
	{
		cout << "Way to go!" << endl;
		score++;
	}
	cout << "\n";
	cout << "What datatype do you need to use when you're dealing with numbers that has decimals?" << endl;
	cout << "1. bool" << endl;
	cout << "2. void" << endl;
	cout << "3. double" << endl;
	cout << "4. char" << endl;
	cout << "\n" << endl;
	cin >> choice;

	if (choice != 3)
	{
		cout << "Sorry, you are incorrect." << endl;
	}
	else
	{
		cout << "Way to go!";
		score++;
	}
	cout << "\n";
	cout << "Which of the following is true about char?" << endl;
	cout << "1. It performs integer division if both operands are integers." << endl;
	cout << "2. It is also called a constant." << endl;
	cout << "3. It is a preprocessor directive" << endl;
	cout << "4. It is used to hold single characters or very small integer values" << endl;
	cout << "\n" << endl;
	cin >> choice;

	if (choice != 4)
	{
		cout << "Sorry, you are incorrect." << endl;
	}
	else
	{
		cout << "Way to go!";
		score++;
	}
	cout << "\n";
	cout << "What is the definition of bool?" << endl;
	cout << "1. Bool represents values that are true or false." << endl;
	cout << "2. It has values that are stored as integers." << endl;
	cout << "3. In bool, false is 0 and true is 1." << endl;
	cout << "4. All of the above." << endl;
	cout << "\n" << endl;
	cin >> choice;

	if (choice != 4)
	{
		cout << "Sorry, you are incorrect." << endl;
	}
	else
	{
		cout << "Way to go!";
		score++;
	}
	cout << "\n";
	cout << "What do you need to put on the header in order to utilize string?" << endl;
	cout << "1. #include (stream)" << endl;
	cout << "2. #include <string>" << endl;
	cout << "3. #include string" << endl;
	cout << "4. #include <iomanip>" << endl;
	cout << "\n" << endl;
	cin >> choice;

	if (choice != 2)
	{
		cout << "Sorry, you are incorrect." << endl;
	}
	else
	{
		cout << "Way to go!";
		score++;
	}

	cout << "\n";
	score1 = score * 100 / 5;
	cout << "The quiz is now over." << endl;
	cout << "Student's name: " << name << endl;
	cout << "Overall quiz score: " << score << " out of 5" << endl;
	cout << "Your percentage on the quiz: " << score1 << "%" << endl;
	cout << "Thank you for taking this quiz. It will be added in your grade." << endl;

	return 0;
closed account (48T7M4Gy)
http://www.cplusplus.com/doc/tutorial/files/
Topic archived. No new replies allowed.