• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 5 páginas
Otro

Review for UnsortedLists and SortedLists

Document preview thumbnail
Vista previa 2 fuera de 5 páginas

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.

Vista previa del contenido

#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;

Información del documento

Subido en
6 de noviembre de 2025
Número de páginas
5
Escrito en
2025/2026
Tipo
Otro
Personaje
Desconocido
$25.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Vendido
0
Seguidores
0
Artículos
68
Última venta
-



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes