0% found this document useful (0 votes)
6 views

C++ Project

The program is designed as a simple quiz system that allows users to take quizzes in C++, Java, and HTML using a console-based interface. It incorporates features like multiple choice questions, randomization of questions, and a scoring system. The program structure consists of a student structure to store user data, quiz functions for each subject, and a main loop for user interaction. Recommendations to improve the program include adding input validation, replacing magic numbers with constants, improving code readability and security, and providing more comprehensive function definitions and comments.

Uploaded by

aliroomanq
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

C++ Project

The program is designed as a simple quiz system that allows users to take quizzes in C++, Java, and HTML using a console-based interface. It incorporates features like multiple choice questions, randomization of questions, and a scoring system. The program structure consists of a student structure to store user data, quiz functions for each subject, and a main loop for user interaction. Recommendations to improve the program include adding input validation, replacing magic numbers with constants, improving code readability and security, and providing more comprehensive function definitions and comments.

Uploaded by

aliroomanq
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

ICP OPEN ENDED LAB

Name: Ali Rooman


Roll number: 23TL010
Subject: ICP Practical
Program: Quiz system program in C++
Submitted to: Sir Talha Kaim Khani
Program Report: Quiz System

Introduction:
The program is designed as a simple quiz system that allows users to take quizzes in
C++, Java, and HTML. It utilizes a console-based interface and incorporates features
such as multiple-choice questions, randomization of questions, and a scoring
system. The structure of the program involves a student structure to store user
information, various functions for each subject's quiz, and a main loop for user
interaction.

Program Structure:
The program is structured in C++ and consists of several key components:

Header Files:
include<iostream> #include<conio.h> #include<cstdlib> #include<windows.h>
• #include<iostream>: This includes the Input/Output stream library for
handling input and output operations.
• #include<conio.h>: This includes the console input/output functions (e.g.,
getch()).

• #include<cstdlib>: This includes the C Standard Library, which provides


general utilities (e.g., rand()).
• #include<windows.h>: This includes the Windows API for using functions
related to console manipulation.

Structure Definition:

• Defines a structure named student with four members: nam (name), rollno
(roll number), marks (quiz marks), and random (random number).
Function Declaration:

• The program declares the following functions.

Global Variable:
• Declares a global variable of type student named st.

Quiz Function (cppp):


• This function conducts a quiz on C++ with a set of five questions.
• It uses a random number generator to select questions and an array (arr)
to ensure that a question is not repeated.
• For each question, it displays options, takes user input, checks
correctness, and updates the user's marks.
• Similar functions (java and html) are mentioned but not defined in the
provided code.

Result Function (result):


• Displays the student's name, roll number, quiz marks, percentage, and pass/fail
status based on the percentage.

Main Function (main):


• The main function is where the program execution begins.
• It uses a do-while loop to allow the user to perform multiple quizzes until they
choose to terminate.
• It takes input for student name and roll number.
• Based on the user's selection, it calls the respective quiz function (cppp, java, or
html) and then displays the quiz result.
• After each iteration, it asks the user if they want to continue.
Points to be noted:

• The getch() function is used to read a single character without echoing it to the
console.
• The system("CLS") function is used to clear the console screen.
• The code lacks proper error handling for user inputs and may have security
issues related to buffer overflows (e.g., using gets for input). It's recommended
to use safer alternatives like fgets or getline.
• The goto statement is used for flow control, which is generally considered bad
practice and can make the code less readable and harder to maintain.

Recommendations and Improvements:

• Security and User Input:


• Replace the usage of gets with safer alternatives like cin.getline to
prevent buffer overflows.
• Code Readability:
• Enhance code readability by following consistent naming conventions for
functions and variables.
• Input Validation:
• Implement input validation to handle incorrect user inputs, preventing
potential runtime errors.
• Magic Numbers:
• Replace magic numbers with named constants to improve code
maintainability.
• Function Definitions:
• Provide the content for the cppp(), java(), and html() functions for a
comprehensive review.
• Comments:
• Add comments to explain complex logic, improve code documentation,
and make the program more understandable.
Program Screenshots:
First it will ask the student’s name and roll number.

Then it will give the student different Quizzes

Suppose a student attempts C++ Quiz then this program will ask 5 MCQ’s.
In the end it will show your results and ask whether to play again or terminate the program.

Conclusion:
The quiz system program provides a basic framework for a console-based quiz
application. By addressing the recommendations mentioned above, the program can
be further enhanced in terms of readability, security, and user experience.
Additionally, the effectiveness of the quiz system heavily depends on the quality and
relevance of the quiz questions provided in the quiz functions.

You might also like