Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4,6 TrustPilot
logo-home
Other

Review for UnsortedLists and SortedLists

Rating
-
Sold
-
Pages
5
Uploaded on
06-11-2025
Written in
2025/2026

The program is a quiz application designed to review concepts related to Unsorted Lists and Sorted Lists. It consists of multiple-choice questions and string input questions, with functionality to evaluate user responses and provide feedback. Key components include: - **Variables**: Used to track user input, correct answers, and scores. - **Functions**: - `checkCharAnswers` and `checkStringAnswers`: Validate single character and string answers. - `counting`: Updates the total score based on correctness. - `charMessage` and `stringMessage`: Provide feedback for individual answers. - `displayResult`: Summarizes the final score and performance. - `question1` through `question10`: Implement the quiz questions. The program guides users through the questions, collects answers, and displays results at the end, aiming to enhance understanding of the covered topics.

Show more Read less

Content preview

#include "UnsortedSorted.h"

int static counter = 0;
int static total = 0;
char input;
char answer;
string typedInput;
string typedAnswer;
bool correct;

bool checkCharAnswers(char input, char answer);
bool checkStringAnswers(string typedInput, string typedAnswer);
void counting(bool correct);
void charMessage(bool correct, char answer);
void stringMessage(bool correct, string typedAnswer);
void displayResult(int counter, int total);

void question1();
void question2();
void question3();
void question4();
void question5();
void question6();
void question7();
void question8();
void question9();
void question10();

int main()
{
cout << "WELCOME to the review for UnsortedLists and SortedLists" << endl;
cout << "If you find any errors or have any ideas to better improve my code,
please let me know. I might not have spent a million hours putting this together."
<< endl << endl;
cout << "NOTE: Be wary that by using strings to hold standard input, whitespace
is also taken into consideration when comparing answers. Always check the outputted
answer when the program claims your answer was 'wrong'" << endl << endl;
question1();
question2();
question3();
question4();
question5();
question6();
question7();

displayResult(counter, total);
}

void question1()
{
answer = 'A';

cout << endl <<
"--------------------------------------------------------------------" << endl;
cout << "When deleting an item in an unsorted list, what do you have to check
first?" << endl;
cout << "A. if the list is empty" << endl;
cout << "B. if the list is full" << endl;
cout << "C. if the user inputted numbers" << endl;

, cout << "D. if the user provided their name" << endl;

counter++;
cout << "Type the letter for your answer... ";
cin >> input;

correct = checkCharAnswers(input, answer);
counting(correct);
charMessage(correct, answer);
}

void question2()
{
typedAnswer = "midpoint = (first + last)/2;";
string typedAnswer2 = "midpoint = (last + first)/2;";

cout << endl <<
"--------------------------------------------------------------------" << endl;
cout << "Referring to the binary search discussed in lecture and homework,
there are three variables named: 'first', 'last', and 'midpoint'. Write the math
expression to calculate the midpoint." << endl;
cin.ignore();
cout << "Type your answer (don't forget the semicolon)... ";
getline(cin, typedInput);

counter++;
counting(correct);
if (checkStringAnswers(typedInput, typedAnswer) == true ||
checkStringAnswers(typedInput, typedAnswer2) == true)
{
cout << "Good job" << endl;
correct = true;
}
else
{
correct = false;
stringMessage(correct, typedAnswer);
cout << endl;
cout << "OR" << endl;
cout << endl;
stringMessage(correct, typedAnswer2);
}
}

void question3()
{
answer = 'B';

cout << endl <<
"--------------------------------------------------------------------" << endl;
cout << "What is the Big O for a binary search of a SortedList list?" << endl;
cout << "A. 0(1)" << endl;
cout << "B. 0(log n)" << endl;
cout << "C. 0(n)" << endl;
cout << "D. 0(ln n)" << endl;

counter++;
cout << "Type the letter for your answer... ";
cin >> input;

Written for

Document information

Uploaded on
November 6, 2025
Number of pages
5
Written in
2025/2026
Type
OTHER
Person
Unknown
$25.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
tinahuynh

Get to know the seller

Seller avatar
tinahuynh California State University, Long Beach
View profile
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
8 months
Number of followers
0
Documents
68
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions