Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ Programming, Read data from file store utilizing structs and display each question read from file! #include #include #include #include #include #include using namespace std;

c++ Programming, Read data from file store utilizing structs and display each question read from file!

#include

#include

#include

#include

#include

#include

using namespace std;

#define NUM_CHOICES 4

struct Choices {

string text[4];

string answer;

bool shuffle;

};

Struct Questions {

string ID;

string text;

Choices choices;

int points;

};

// This function reads all the questions from sampledata.txt and returns the amount of questions in the file! , Count will go up by one everytime an ID is read. Data reading is stopped by END

int readQuestions (Questions questionchoices[]) {

return 0;

}

// This function displays the contents of a question.

void displayQuestion (Questions questionschoices[], int num) {

}

int main () {

// Declarations for questionchoices

Question questionchoices[100];

int numQuestions;

return 0;

}

sampledata.txt

image text in transcribed

Getline to be used where necessary!

image text in transcribed

Placement You are third place in a race. What place are you in if you pass the person in 1st place? 1st 2nd 3rd None of the above 2nd 0 1 Days How many months have 30 days? 2 1 None of the above. Depends if there's a leap year or not. None of the above. 0 1 ID OF QUESTION QUESTION? CHOICE 1 CHOICE 2 CHOICE 3 CHOICE 4 CORRECT ANSWER SHUFFLE RESPONSE MARK AWARDED Dead A farmer has 17 chickens, all of them but 8 die. How many chickens are still standing? 8 9 25 35 8 1 1 END Reading a String with Spaces The getline function can be used to read a string containing spaces. It reads all the characters in a line. Suppose input file is an ifstream that has already been opened and line is a string. The getline function can be used to read all the characters from the next line of input in the file into line: ifstream inputFile; string line; getline (inputFile, line)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions