1
MINI PROJECT
On
(Quiz App)
In
Programming in C Lab
BACHELOR OF TECHNOLOGY
IN
Artificial Intelligence and Machine Learning
SUBMITTED BY
Name: Bontha Mallikarjun Reddy
(PRN: 23070126026)
Under the Supervision of
Ms. Suman Tanwar,
Assistant Professor
SYMBIOSIS INSTITUTE OF TECHNOLOGY, PUNE – 412115
(A CONSTITUENT OF SYMBIOSIS INTERNATIONAL (DEEMED
UNIVERSITY))2023-24
INDEX
2
[Link] Contents Page No.
1
Problem Statement 3
2
Motivation 3
3
Objective 3
4
Methodology of Implementation (Flow Chart/ Pipeline) 3
5
Hardware/Software Used 6
6
Executable Code with Output Screen Shot 6-12
7
Result Analysis 13
8
Learning Outcomes 13-14
1. Problem Statement:
C program on the topic of “Quiz app.”
3
2. Motivation:
The motivation for creating this quiz app is to evaluate the
general knowledge of students. The idea came to me while I
was taking an online physics test, and I thought it would be
great to develop an app that tests students' general knowledge.
The result of my idea is this quiz app.
3. Objective:
Enhanced User Experience and Engagement: Improve user input
handling, quiz functionality, and error handling mechanisms to
ensure a smooth and engaging experience for users. This
includes refining input validation, expanding quiz content, and
providing informative feedback to enhance user satisfaction.
Efficient Data Management and Security: Develop robust
systems for storing and retrieving quiz results securely,
optimizing scoring mechanisms, and implementing security
enhancements to safeguard user data. This involves fine-tuning
data storage, ensuring data integrity, and implementing security
best practices to protect against potential vulnerabilities.
Optimized Performance and Accessibility: Focus on optimizing
code performance, enhancing documentation and comments for
maintainability, and integrating user feedback mechanisms to
gather insights for continuous improvement.
[Link]:
Understanding User Input and Data Structure:
Analyze the structure of the Student data type to understand the
information collected from the user, including name, school, and
gender.
Review the get_student_details function to understand how user
input is collected and stored in the Student structure.
Quiz Implementation:
4
Review the quiz function to understand how the quiz questions
are presented to the user and how their responses are evaluated
for correctness.
Analyze the scoring mechanism to understand how the user's
score is calculated based on their responses to the quiz
questions.
File Handling and Data Storage:
Review the save_results function to understand how quiz results
are stored in a text file (quiz_results.txt).
Ensure understanding of how student information and quiz
scores are formatted and written to the file for later retrieval and
analysis.
Testing and Error Handling:
Conduct testing to ensure the robustness of user input handling,
quiz functionality, and file handling processes.
Identify potential edge cases and error scenarios and implement
appropriate error handling mechanisms to provide informative
error messages and ensure smooth operation of the program.
User Feedback and Iteration:
Implore user feedback to gather insights on usability,
functionality, and potential areas for improvement.
Incorporate user feedback into future code iterations to enhance
the application's overall user experience and functionality.
Flowchart:
5
6
5. Hardware/Software Used:
This code was written on a compiler called ’Dev C++’.
This was written in the C Language under the stdio.h header file.
6. Executable Code:
#include <stdio.h>
struct Student {
char name[50];
char school[100];
char gender;
};
void get_student_details(struct Student *student) {
printf("Enter your name: ");
scanf("%s", student->name);
printf("Enter your school name: ");
scanf("%s", &student->school);
printf("Enter your gender (M/F): ");
scanf(" %c", &student->gender);
7
int quiz()
{
int score = 0;
char answer;
printf("\nQuestion 1: What is the capital of France?\n");
printf("A) London\nB) Paris\nC) Rome\nYour answer: ");
scanf(" %c", &answer);
if (answer == 'B' || answer == 'b') {
printf("Correct!\n");
score++;
} else {
printf("Incorrect. The correct answer is B) Paris.\n");
}
printf("\nQuestion 2: Which planet is known as the Red Planet?\n");
printf("A) Earth\nB) Mars\nC) Venus\nYour answer: ");
scanf(" %c", &answer);
if (answer == 'B' || answer == 'b') {
printf("Correct!\n");
score++;
} else {
printf("Incorrect. The correct answer is B) Mars.\n");
}
8
printf("\nQuestion 3: What is the largest mammal?\n");
printf("A) Elephant\nB) Blue whale\nC) Giraffe\nYour answer: ");
scanf(" %c", &answer);
if (answer == 'B' || answer == 'b') {
printf("Correct!\n");
score++;
} else {
printf("Incorrect. The correct answer is B) Blue whale.\n");
}
printf("\nQuestion 4: Who is the current prime minister?\n");
printf("A) Gowtham gambir \nB) Narendra Modi\nC) Rahul Gandhi\nYour
answer: ");
scanf(" %c", &answer);
if (answer == 'B' || answer == 'b') {
printf("Correct!\n");
score++;
} else {
printf("Incorrect. The correct answer is B) Narendra Modi.\n");
}
printf("\nQuestion 5: What is the most used letter in the English language??\
n");
printf("A) C\nB) D\nC) E\nYour answer: ");
scanf(" %c", &answer);
9
if (answer == 'C' || answer == 'c') {
printf("Correct!\n");
score++;
} else {
printf("Incorrect. The correct answer is C)E.\n");
}
printf("\nQuestion 6: Of the various types of light in natural sunlight, which
one causes sunburn?\n");
printf("A) Ultra Violet\nB) Infrared rays \nC) X-rays \nYour answer: ");
scanf(" %c", &answer);
if (answer == 'a' || answer == 'a') {
printf("Correct!\n");
score++;
} else {
printf("Incorrect. The correct answer is A) Ultra Violet.\n");
}
printf("\nQuestion 7: Who is the author of The Universe in a Nutshell, On the
Shoulders of Giants, and A Brief History of Time??\n");
printf("A) Leonardo DaVinci\nB) Elon musk\nC) Stephen Hawking\nYour
answer: ");
scanf(" %c", &answer);
if (answer == 'C' || answer == 'c') {
printf("Correct!\n");
score++;
} else {
10
printf("Incorrect. The correct answer is C) Stephen Hawking.\n");
}
return score;
}
void save_results(const struct Student *student, int score) {
FILE *file = fopen("quiz_results.txt", "a");
if (file == NULL) {
printf("Error opening file.\n");
return;
}
fprintf(file, "Name: %s\n", student->name);
fprintf(file, "School: %s
\n", student->school);
fprintf(file, "Gender: %c\n", student->gender);
fprintf(file, "Score: %d\n\n", score);
fclose(file);
}
int main() {
struct Student student;
get_student_details(&student);
int score = quiz();
11
save_results(&student, score);
printf("\nQuiz completed!\n");
printf("Your score: %d out of 7\n", score);
if(score==7)
{
printf("You are a genius well done!!");
}
else
{
printf("You are a average student !!");
}
printf("\n");
char feedback[100];
printf("Write your feedback of your experience: ");
scanf("%99s", feedback);
printf("\nThank you for your feedback!\n");
return 0;
}
Output Screenshots:
12
7. Result Analysis:
13
The code successfully captures student details, administers a quiz,
saves the quiz results and student information to a text file, and
collects feedback from the user about their experience. However,
there are areas for improvement. Error handling and data validation
should be implemented to ensure robustness and prevent unexpected
behaviour. Additionally, the format specifier for printing the school’s
name in the `save_results` function should be corrected to `%s`. The
feedback collection mechanism could be enhanced by storing
feedback in a separate file or database for better organization and
analysis. Overall, while the code achieves its basic functionality, there
is room for refinement to enhance error handling, data validation, file
formatting, feedback collection, and user experience.
8. Learning Outcomes:
1. Enhanced User Experience and Engagement: Through the
development of the quiz app, the understanding was gained in
improving user input handling, quiz functionality, and error handling
mechanisms to ensure a smooth and engaging user experience. This
involved refining input validation, expanding quiz content, and
providing informative feedback to enhance user satisfaction.
2. Efficient Data Management and Security: Experience was acquired
in developing robust systems for storing and retrieving quiz results
securely, optimizing scoring mechanisms, and implementing security
enhancements to safeguard user data. This included fine-tuning data
storage, ensuring data integrity, and implementing security best
practices to protect against potential vulnerabilities.
14
3. Optimized Performance and Accessibility: Skills were developed in
optimizing code performance, enhancing documentation and
comments for maintainability, and integrating user feedback
mechanisms to gather insights for continuous improvement. This
encompassed understanding code efficiency, documentation
practices, and the importance of user feedback in iterative
development.
4. File Handling and Data Storage: Proficiency was gained in file
handling and data storage techniques, particularly in understanding
how to store quiz results and student information in a text file.
Reviewing and implementing file handling functions acquired
knowledge in formatting data and ensuring proper storage and
retrieval.