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?
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
usingnamespace 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;