C++ :: How To Create True False And Multiple Choice Questions Using Text Files

Jan 7, 2015

So im trying to create a quiz using c++ that incorporates three different types of questions. These are the standard one answer question, true false questions and multiple choice questions.

How to create the true false and multiple choice questions?

One way that i came up with looks like this

Question A answer1 B answer2;

View 2 Replies


ADVERTISEMENT

C :: Program That Grades A True / False Quiz - Data Available In Text File

Oct 14, 2014

You are to write a C program that grades a true-false quiz. The quiz data will be available in a text file; here is an example:

Quiz #8 (09/22/14) (corrected version)
TTFTTFTFTF
0080 TTFTTFTFTF
0340 TTFTFFTFTF

The first line in the data file is a comment that you may assume can be up to 80 charac- ters long; it cannot be blank. The second line contains the answer key for the 10-question true-false quiz. The following lines in the data file contain a student's id number in column 1 followed by their answers for the quiz in column 2. A 0 (zero) on a line by itself indicates that there are no more students to process.

Write a program that first reads in (from standard input; more on this in a moment) the comment line and answer key as strings followed by each student's data. Store the student's id numbers in an array. You are to "grade" each student's quiz using the key provided fol- lowed by recording their scores (in a second array) in order to be able to print them out later. You do not need to use an array of strings or characters in your program. Write your program allowing for up to 100 students, and you may assume that at least 1 student will have taken the quiz.

You should create test data text files and provide the data to your program using redirection from the command line (see the sample run below). Your program should output the number of students who took the quiz, the average score, the best score, and a table showing each student's id, score, and grade. The formatting, spacing, and labels in your output should 1 match the sample run below exactly.

Your program should determine each student's grade as follows: if the score is equal to the best score b or b−1, give an A. If it is b−2, award a B. Give C's for any score that is equal to b−3 or b−4, a D for b−5 and an F for all others.

Alright So I'm just stuck at comparing the key answer with student answer here is my code comparing one student's answer with the answer key . is that right ?? One more thing for some reason when i try to print answer[0] the result is nothing why is that

Code:
#include<stdio.h>
int main(void) {
char comment[80];
char answer [10];
char studentans [10];
int n=0,i=0,x=0;
int ID[10];

[Code] .....

View 1 Replies View Related

C :: Create Multiple Choice Quiz Works But With A Warning

Apr 10, 2013

I am trying to create a multiple choice quiz so I can learn the menu at my new job, while doing a side project but I am having a warning when outputting. Speaking of side projects, is this a kind of side project people are looking for on a resume?

Code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
}

[code]....

View 8 Replies View Related

C++ :: True / False About Function Parameter

Sep 11, 2014

is it true or false

a function like void myfun(int num){} can receive type "int var" but can't receive type "const int var"

AND

a function like void myfun(const int num){} can receive both type "int var" and also type "const int var"

View 3 Replies View Related

C++ :: How To Switch Between Boolean True / False Logic Within Do / While Loop

Mar 25, 2014

I have a hit a snag in a number guessing game program. I was given a half-completed program and told to use functions to complete the missing pieces. It looks unwieldy, but this is how it is supposed to be. I have temporarily made the random guess value visible for troubleshooting purposes.

#include <iostream>
#include <time.h>
#include <stdlib.h>
using namespace std;
int welcome() {
cout << " Welcome to the hi-low game!" << endl;

[code]....

The issue lies within this piece of code:

checkGuess(guess, correct); done = false; //either true or false
} while (!done);
cout << "Congratulations, you got it!" << endl;
return 0;
}

I need to manipulate the Boolean variable done so that it registers as false when the user inputs a number higher or lower than the randomly selected value. However, if the user guesses correctly, done will become true and the program will end.

As it stands now, the program will not terminate, and if I set done equal to true like so:

checkGuess(guess, correct); done = true; //either true or false
} while (!done);
cout << "Congratulations, you got it!" << endl;
return 0;
}

Every number the user inputs will register as correct instead of the one right guess.

View 4 Replies View Related

C++ :: Palindrome That Takes A Vector Parameter And Returns True Or False

Apr 26, 2014

Write a function palindrome that takes a vector parameter and returns true or false according to whether the vector does or does not read the same forward as backward (e.g., a vector containing 1, 2, 3, 2, 1 is a palindrome, but a vector containing 1, 2, 3, 4 is not).

Code :
#include <vector>
#include <iostream>
using namespace std;
void palindrome(vector<int>);

[Code] .....

View 4 Replies View Related

C++ :: Binary Search Function - Return True If Element Inputted By User Found In Array And False If Not

Nov 9, 2014

I was instructed to write a binary search function which would return true if an element, inputted by the user, was found in the array, and false if it was not. I'm not sure why, but my function always returns false. My code is as follows.

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
//binary search function
bool search (int array[], int item)

[Code] ....

Why my code does not fulfill it's purpose???

View 7 Replies View Related

C++ :: Display Last 1000 Lines From Multiple Text Files (log Files)

Jan 16, 2014

I am writing a piece of code that requires me to display the last 1000 lines from a multiple text files (log files). FYI, I am running on Linux and using g++.

I have a log file from which - if it contains more than 1000 lines, I need to display the last 1000 lines. However, the log file could get rotated. So, in case where the current log file contains less than 1000 lines, I have to go to older log file and display the remaining. For e.g., if log got rotated and new log file contains 20 lines, I have to display the 980 lines from old log file + 20 from current log files.

What is the best way to do this? Even an outline algorithm will work.

View 6 Replies View Related

C++ :: Make Program That Prints Out 10 Random Questions From 15 Questions?

Oct 29, 2013

I need to make a program that prints out 10 random questions from the 15 questions in a .txt file, and then print out the choice IN RANDOM.

View 7 Replies View Related

C++ :: Passing In Multiple Text Files

Oct 6, 2014

I have been working on code for quite some time and am able to successfully read in a text document and take certain words and information that I need. The issue is that I need to read in close to 100 plus documents and was wondering how I could read in the multiple documents. I thought about creating a structure of arrays and have each text document be an element and walk through taking each document but I am not sure how this works.

View 8 Replies View Related

C++ :: Reading Multiple Text Files In Program

May 31, 2013

I want to know how to read multiple text files in this program... I have 5 text files(order1,order2,...order5).

#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<windows.h>
using namespace std;
class{

[Code] ....

View 3 Replies View Related

C++ :: Randomized Multiple Choice

Feb 20, 2012

I have gotten my code sorted out, and now it works. But to be adaptable to 3pi robots, which I will be loading it into eventually, the user has to be given three letter (a, b, c) multiple choices for answer input to the math questions. The three choices have to be randomized everytime the program loops too. Currently it just runs on number input.

Code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
int menu();
void addition(int *Preward); // function to return truth values
void subtraction(int *Preward);

[Code] ....

View 4 Replies View Related

C# :: Multiple Choice Symptom Checker?

Mar 9, 2015

I'm doing a project through college which is a diagnostic and support tool for Windows OS's. The application at the moment has a simple expert system which is a Combobox with strings that relate to common PC problems. Then those strings are put through a switch statement and relevant commands are shown to fix the problem i.e. "My printer is not working" will disable all buttons except for printer management, spooler folder etc.

My supervisor who marks my project has said this isnt good enough and wants a more layered hierarchy approach so he's looking for 3-4 groupboxes with tickboxes inside them and users tick the boxes that relate to their problem which will give the functions to support. The only way I can see to do this at the moment is a massive nested switch statement that is really not worth the time. There are 60+ functions in my program so you can imagine how long the switch would be trying to pick and iterate through all of the possible answers.

I'm just trying to figuire out an easier way to do this, rather than a massive switch statement. Something like WebMD which has 4-5 tick boxes and can give out the same answer for different symptoms.

I've attached a Flow Chart I made of the hierarchy Im trying to go for [URL] .....

View 1 Replies View Related

C++ :: Read Multiple Text Files And Count Occurrences Of Word

Jun 8, 2013

I am supposed to read(scan) data from a folder with multiple(21578) text files, and file names are numbered from 1 to 21578,and read each word that occurs in a text file, and count the number of times it occurs in the entire folder,i.e; in all the files how do i go about it? I've tried this so far..but it isn't working..

#include <iostream>
#include <map>
#include <string>
using namespace std;
void incrementString(map<string, int> &theMap, string &theString) {
if(theMap.count(theString)) {

[Code] ....

View 1 Replies View Related

C/C++ :: Assigning Variable From Multiple Choice Answer

Oct 29, 2014

I tried to create a multiple choice list and I want to assign the value of the answer option chosen by the user so I can use it later on in the code. Later on in the code i've asked how many people (p) want a drink and multiplied it by the chosen size to calculate the price c = p * n where c is cost, n is price and p is number o of people At the bottom i tried to assign parameters where depending on what option the user has chosen n will be assigned to the chosen value...

{
printf("SELECT TYPE OF PAINT:"); /*multiple choice of paint */
printf("1. Large ");

[Code]....

View 1 Replies View Related

C++ :: Multiple Choice Function - Using Character As Parameter

Feb 20, 2012

I have a multiple choice function below that is part of a larger program but I am having trouble having it operate with characters as inputs and arguments. It has to be a character input, but I kinda want it to act like an integer, how do i do that?

Code:
void addition(int *Preward) //function that is called by the users selection {
int random1, random2;
int order;
int one, two, three;
int rando1, rando2;
char a, b, c; // ERROR

[Code] ....

View 2 Replies View Related

C++ :: Make Program To Create New Text Files?

Jul 9, 2013

I want to make a program that can know the current time and create a new .txt file.For example if its Monday to day then when its Tuesday it crates a new txt file called Tuesday.I really don't know how to go about this.I know i will need to use the time.h library.

View 4 Replies View Related

C++ :: Grading Multiple Choice Test - Getting Infinite Loop?

Nov 4, 2013

I am writing a program for grading a multiple choice test. The test data is pulled in from another file. My problem is that its only pulling in the first line of data and running an infinite loop without reading the next line of the data file.

My code is as follows:

PrintPurpose ( );
cout << student << " ";
cout << answers << " ";
inData >> key;

[Code].....

View 1 Replies View Related

C++ ::  Multiple Files Causes (Multiple Definition) Error?

Jul 15, 2013

I'm using multiple C++ files in one project for the first time. Both have need to include a protected (#ifndef) header file. However, when I do that, I get a multiple definition error.

From what I found from research, adding the word inline before the function fixes the error. Is this the right way to do this, and why does it work? Should I make a habbit of just declaring any function that might be used in two .cpp files as inline?

View 5 Replies View Related

C/C++ :: Program That Opens Text File And Checks Usernames Listed In Text Files?

Jun 5, 2014

I want to make a program that opens a text file and checks the usernames listed in the text files to see if the names are registered on a site such as twitter. How easy would this be to make, what things would I need to know?

View 4 Replies View Related

C++ ::  Headers With Multiple CPP Files

Mar 22, 2013

So I have a rather large (for me) project, requiring me to have two .cpp files and a header. Anyway, both of the .cpp files #include the header file, but I recieve linker errors because the variables and functions in the header are declared and defined twice (once in each .cpp file). How am I supposed to do this?

View 8 Replies View Related

C# :: Classes Across Multiple Files?

Sep 24, 2014

We typically don't bother with massive, monolithic code files that get processed from top to bottom. In the Object Oriented world, code files don't mean much. In fact, in C#, I could have multiple classes defined in one file, or have one class split across several files.

View 7 Replies View Related

C/C++ :: Using Multiple Files And Includes

Mar 23, 2014

I am struggling with the concept of having different ccp's and header files. I made a really bad example project for representation, but basically my question is are any of the #includes unnecessary that I have? Technically it functions, but if I am doing it wrong I want to prevent myself from starting bad habits in the future. My code just basically uses strings and sets a name and prints it. My code is really bad, but I wanted to just use includes in such a way for a quick example.

//MAIN.CCP
#include "functions.h"
using namespace std;
int main()

[Code]......

View 1 Replies View Related

C/C++ :: How To Get Multiple Source Files To Run One After The Other

May 16, 2012

I am trying to run multiple source files but right after the first one finishes running the program closes and doesn't move on ...

View 2 Replies View Related

C++ :: How To Put A Limit Of 100 Questions To Be Outputted

May 8, 2014

Why is this code crashing ? and how do I put a limit of 100 questions to be outputted but not for the test to end ? Also this doesn't seem to be randomizing at all ?

#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
vector<string> questions;
vector<string> answers;

[Code] .....

View 11 Replies View Related

C :: Compile Multiple Source Files

Mar 7, 2013

How I can compile multiple source file in visual studio 2012 ???

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved