Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions AvaFinalProject.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
Ava N.
July 9, 2016

Final Project Proposal:

For my final project, I would like to create a quiz show, similar to Jeopardy. The objective of the game is to answer as many questions correctly as possible. I will be adding a time limit as well.

The questions would be divided into different categories. For example, under the "computer science" category, the lowest, or '100' slot question might state: 'This device was used to solve math problems before the invention of electricity." The answer, which would not be case sensitive, would be inputed by the contestant/player. Also, I am deciding whether to require the player input to include "what is ..." before the answer. This game will be created for a single-player, but if I have time, I would like to make a 2, 3, or 4 player option as well.

An example of a loop I would use is for the fill-in the answer section. If the correct answer is chosen, then the point goes to the player who asked the question (under a time limit). If that person does not answer correctly or under the time limit, it will go to the next player, and if that player answers correctly, then the original amount of points will get split in half. I will also use functions for the input of the contestant.

I am choosing this project because taking part in a quiz show or game is so much fun, and playing one that I create would be great. I am excited to develop the game design and decide how I will arrange the 'answers' and the 'questions', and where I will put the timer, and arrange different color schemes.

Libraries I will use are the include the ones we have used in class: stdio.h, string.h, math.h, etc. I plan to use the time.h library for the timer. For graphics, I may want to use Cairo, although I have never used that library before.

This is my Final Project Proposal and I am excited to start working on it (once it is approved)!
30 changes: 30 additions & 0 deletions FinalProject/answer.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
Army
Switzerland
Hyena
New York City
Mudd
Winter
700
February
Bonjour
Whale
1492
Abacus
Orange
P
Hydrogen
24
Nile River
Mount Everest
Elvis Presley
Damascus
Sicily
Venezuela
Retriever
1984
Theodore Roosevelt
6
1509
Queue
Ada Lovelace
Yes
1 change: 1 addition & 0 deletions FinalProject/extra.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@

30 changes: 30 additions & 0 deletions FinalProject/questions.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1. What is a group of frogs known as?
2. What country has the highest environmental performance index?
3. Which animal laughs like human being?
4. In which city is manhattan located?
5. In which building is the Columbia HSP for Intro to Programming in C?
6. During what season do animals hybernate?
7. How much wood would a woodchuck chuck if a woodchuck could chuck wood (answer in pounds)?
8. In what month is Valentine's Day?
9. How do you say 'Hello/Good morning' in french?
10. Which underwater creature is bigger: Dolphin or Whale?
11. In what year did Christopher Columbus sail the ocean blue?
12. What device was used to solve math problems before the invention of electricity?
13. What color comes after red in the rainbow?
14. What is the 16th letter in the alphabet?
15. What is the first element in the periodic table (not in scientific notation)?
16. How many students are in the Introduction to Programming in C class?
17. What is the longest river in the world? (include 'River' at the end of answer)
18. What is the highest mountain in the world?
19. Who is known for being the King of Rock 'n Roll?
20. What is the world's oldest city?
21. What is the largest island in the Mediterranean sea?
22. In what country is the highest waterfall in the world?
23. What is the most popoular breed of dog?
24. In which year was the first computer sold with a mouse?
25. Who was the youngest President in the United States?
26. How many legs do butterflies have?
27. In which year did Henry VIII become King of England?
28. What is a linear data structure in which elements are added on one end and removed from the other?
29. Which female mathematician developed the first algorithm for the Analytical Machine?
30. Did you enjoy playing? (Yes/No)
Binary file addedFinalProject/quiz_game
Binary file not shown.
170 changes: 170 additions & 0 deletions FinalProject/quiz_game.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
//Ava N.'s

//REAL VERSION -- Ava's Quiz Show
//Columbia HSP FInal Project
//Intro to Programming in C
//Due: July 15, 2016

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>


void help(){ //gives instructions of the game
system("clear");
printf("\n\n Instructions:");
printf("\n ------------------------------------------------------");
printf("\n ................... Ava's Quiz Show ....................");
printf("\n >> You have to be able to answer 30 questions correctly.");
printf("\n >> All of the questions require fill-in answers.");
printf("\n >> This game is case-sensitive, so all answers have to");
printf("\n have the first letter of each word uppercase.");
printf("\n >> If the question asks for a number, answer with a number.");
printf("\n >> The maximum number of points a you can get is 11.");

printf("\n >> You will not be penalized for incorrect answers.");

printf("\n\n\t**************Good Luck*******************\n\n");
printf("\n\n\t Press 'enter' to continue to the main menu\n");
}



//start of the game show
int main(void){

system("clear");
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[100]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i; //variable for loop that checks contestants answers
int e; //variable for going through the questions.txt file
const int num_ques=29; //includes number of questions
char choice; //main menu variable
int countr = 0; //score

mainhome:
system("clear"); //source: http://stackoverflow.com/questions/15102976/how-to-clear-screen-from-simple-c-program
//printf("\t\t\tC PROGRAM QUIZ GAME\n");
printf("\n\t\t________________________________________");

printf("\n\t\t\t * WELCOME *");
printf("\n\t\t\t * to *");
printf("\n\t\t\t * AVA'S GAME SHOW *");
printf("\n\t\t ____*_*_*_*_*_*_*_*_*_*_*_*____");
printf("\n\t\t________________________________________");
printf("\n\t\t\t BECOME THE CHAMPION!!! ") ;
printf("\n\t\t________________________________________");
printf("\n\t\t________________________________________");
printf("\n\t\t > Press S to start the game");
printf("\n\t\t > press H for help ");
printf("\n\t\t > press Q to quit ");
printf("\n\t\t________________________________________\n\n");


printf("\n\n\tAnswers must all begin with an uppercase letter\n\n\n");
//MAIN MENU SELECTION OPTIONS
choice=toupper(getchar());
printf("you entered %c\n",choice);

if (toupper(getchar())=='S')
goto home;
else if (choice=='H'){
printf("you typed in H");
help();
getchar();
goto mainhome;
}
else if (choice=='Q'){
printf("you typed in Q");
exit(1);

}


home:
//HAVING QUESTIONS PRINT ONE AT A TIME
for (e=0; e < num_ques; e++) //loop to go through each question in text file
{
//printf("\nQuestion:");
printf("\n***Type in your answer to the following question:\n\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL)
{
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c

if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL)
{
fprintf(stderr,"Error while reading file\n");
return -1;
}



for (i=0; i < 1; i++)
{
// printf("%d\n",i);
//fprintf(stderr,"DIAGNOSTIC -- the answer: %s\n", ans_arr);
//printf("DIAGNOSTIC -- GUESS variable is:%s\n", guess);
fgets(guess, sizeof(guess), stdin);

//fprintf(stderr,"you answered %s\n",guess);

if (strcmp(ans_arr, guess) == 0)
{
printf("Your guess was correct\n\n");
countr++;
}
else if (guess!=ans_arr)
{
printf("Your guess was incorrect.\n");
printf("The answer was: %s\n\n\n\n", ans_arr);
}
else
{
printf("You ran out of questions.");
}
}
}


fclose(questions);
fclose(answers);

//SHOWING THE CONTESTANT THEIR SCORE - HOW MANY QUESTIONS THEY GOT CORRECT
score:
system("clear");
//score=countr;
//printf("* DIAGNOSTIC -- countr is %d\n",countr);
//printf("* DIAGNOSTIC -- score is %d\n",score);
if(countr>0 && countr<=29){
printf("\n\n\t\t************* CONGRATULATIONS **************");
printf("\n\t\t\t You won %d points! \n", countr);
}

else if(countr==30){ //highest score possible
printf("\n\n\n \t\t*********** Nice Job!! ***********");
printf("\n\t\t\t\t You are the champion!!!!!!!!!");
printf("\n\t\t\t You won %d points! \n",countr);
printf("\t\t Thank You!!");
}
else{
printf("\n\n\t******** You did not win any points ********");
printf("\n\t\t Thanks for playing!. \n");
printf("\n\t\t Better luck next time! \n");
}



return 0;


}
30 changes: 30 additions & 0 deletions FinalProject/readme.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
Ava N.
July 15, 2016
Ava's Quiz Game

This is a quiz show game programmed in C during Columbia HSP. My project takes questions from 'questions.txt' and answers from 'answer.txt' to these questions. There is a 'help' center, a 'quit' command, and a command to start the game. All instructions of how to play the game are inside of the game. This is a one player game.


In my proposal, I mentioned including a timer; however, I decided in the end not to add one. I also stated in my introduction that I would have different slots for different categories with different point systems. I later decided that I would not have different categories but a list of questions that players of 'Ava's Quiz Game' would need to answer. Although I did not have time to include graphics, I created a fun looking 'main menu'!

All of the answers to the questions, if you want to beat the game, are in answer.txt .


I got my idea of how to set up Ava's Quiz Show here: http://www.codewithc.com/quiz-game-mini-project-in-c/



Files used in Ava's Quiz Show: [quiz_game.c], [questions.txt], and [answers.txt]. All other files in Final Code folder were used to test the code in the main file.


I hope you enjoy Ava's Quiz Show!



compile statement:
gcc quiz_game.c -o quiz_game
./quiz_game




Binary file addedFinalProject/sam
Binary file not shown.
59 changes: 59 additions & 0 deletions FinalProject/sample_doc.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
//This is for checking the code of the question-answer section in quiz_game code

#include <stdio.h>
#include <string.h>

int main (void){
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[25]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i;
int e;
const int num_ques=5;
for (e=0; e < num_ques; e++){

printf("Type in your answer to the following question:\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL){ //read 1 line from file
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c
if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL){
fprintf(stderr,"Error while reading file\n");
return -1;
}

for (i=0; i < 1; i++){ //Loop for questions asking
//printf("%d\n",i);
//fprintf(stderr,"the answer: %s\n", ans_arr);
//printf("Please guess the word: \n");
fgets(guess, sizeof(guess), stdin);

fprintf(stderr,"you answered %s\n",guess);
if (strcmp(ans_arr, guess) == 0){
printf("Your guess was correct\n\n");
//continue;
}
else if (guess!=ans_arr){
printf("Your guess was incorrect.\n\n\n");
//continue;
}
else {
printf("You ran out of questions");
//break;
}
}
}


fclose(questions);
fclose(answers);
return 0;
}


Binary file addedFinalProject/temp
Binary file not shown.
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions AvaFinalProject.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
Ava N.
July 9, 2016

Final Project Proposal:

For my final project, I would like to create a quiz show, similar to Jeopardy. The objective of the game is to answer as many questions correctly as possible. I will be adding a time limit as well.

The questions would be divided into different categories. For example, under the "computer science" category, the lowest, or '100' slot question might state: 'This device was used to solve math problems before the invention of electricity." The answer, which would not be case sensitive, would be inputed by the contestant/player. Also, I am deciding whether to require the player input to include "what is ..." before the answer. This game will be created for a single-player, but if I have time, I would like to make a 2, 3, or 4 player option as well.

An example of a loop I would use is for the fill-in the answer section. If the correct answer is chosen, then the point goes to the player who asked the question (under a time limit). If that person does not answer correctly or under the time limit, it will go to the next player, and if that player answers correctly, then the original amount of points will get split in half. I will also use functions for the input of the contestant.

I am choosing this project because taking part in a quiz show or game is so much fun, and playing one that I create would be great. I am excited to develop the game design and decide how I will arrange the 'answers' and the 'questions', and where I will put the timer, and arrange different color schemes.

Libraries I will use are the include the ones we have used in class: stdio.h, string.h, math.h, etc. I plan to use the time.h library for the timer. For graphics, I may want to use Cairo, although I have never used that library before.

This is my Final Project Proposal and I am excited to start working on it (once it is approved)!
30 changes: 30 additions & 0 deletions FinalProject/answer.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
Army
Switzerland
Hyena
New York City
Mudd
Winter
700
February
Bonjour
Whale
1492
Abacus
Orange
P
Hydrogen
24
Nile River
Mount Everest
Elvis Presley
Damascus
Sicily
Venezuela
Retriever
1984
Theodore Roosevelt
6
1509
Queue
Ada Lovelace
Yes
1 change: 1 addition & 0 deletions FinalProject/extra.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@

30 changes: 30 additions & 0 deletions FinalProject/questions.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1. What is a group of frogs known as?
2. What country has the highest environmental performance index?
3. Which animal laughs like human being?
4. In which city is manhattan located?
5. In which building is the Columbia HSP for Intro to Programming in C?
6. During what season do animals hybernate?
7. How much wood would a woodchuck chuck if a woodchuck could chuck wood (answer in pounds)?
8. In what month is Valentine's Day?
9. How do you say 'Hello/Good morning' in french?
10. Which underwater creature is bigger: Dolphin or Whale?
11. In what year did Christopher Columbus sail the ocean blue?
12. What device was used to solve math problems before the invention of electricity?
13. What color comes after red in the rainbow?
14. What is the 16th letter in the alphabet?
15. What is the first element in the periodic table (not in scientific notation)?
16. How many students are in the Introduction to Programming in C class?
17. What is the longest river in the world? (include 'River' at the end of answer)
18. What is the highest mountain in the world?
19. Who is known for being the King of Rock 'n Roll?
20. What is the world's oldest city?
21. What is the largest island in the Mediterranean sea?
22. In what country is the highest waterfall in the world?
23. What is the most popoular breed of dog?
24. In which year was the first computer sold with a mouse?
25. Who was the youngest President in the United States?
26. How many legs do butterflies have?
27. In which year did Henry VIII become King of England?
28. What is a linear data structure in which elements are added on one end and removed from the other?
29. Which female mathematician developed the first algorithm for the Analytical Machine?
30. Did you enjoy playing? (Yes/No)
Binary file addedFinalProject/quiz_game
Binary file not shown.
170 changes: 170 additions & 0 deletions FinalProject/quiz_game.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
//Ava N.'s

//REAL VERSION -- Ava's Quiz Show
//Columbia HSP FInal Project
//Intro to Programming in C
//Due: July 15, 2016

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>


void help(){ //gives instructions of the game
system("clear");
printf("\n\n Instructions:");
printf("\n ------------------------------------------------------");
printf("\n ................... Ava's Quiz Show ....................");
printf("\n >> You have to be able to answer 30 questions correctly.");
printf("\n >> All of the questions require fill-in answers.");
printf("\n >> This game is case-sensitive, so all answers have to");
printf("\n have the first letter of each word uppercase.");
printf("\n >> If the question asks for a number, answer with a number.");
printf("\n >> The maximum number of points a you can get is 11.");

printf("\n >> You will not be penalized for incorrect answers.");

printf("\n\n\t**************Good Luck*******************\n\n");
printf("\n\n\t Press 'enter' to continue to the main menu\n");
}



//start of the game show
int main(void){

system("clear");
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[100]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i; //variable for loop that checks contestants answers
int e; //variable for going through the questions.txt file
const int num_ques=29; //includes number of questions
char choice; //main menu variable
int countr = 0; //score

mainhome:
system("clear"); //source: http://stackoverflow.com/questions/15102976/how-to-clear-screen-from-simple-c-program
//printf("\t\t\tC PROGRAM QUIZ GAME\n");
printf("\n\t\t________________________________________");

printf("\n\t\t\t * WELCOME *");
printf("\n\t\t\t * to *");
printf("\n\t\t\t * AVA'S GAME SHOW *");
printf("\n\t\t ____*_*_*_*_*_*_*_*_*_*_*_*____");
printf("\n\t\t________________________________________");
printf("\n\t\t\t BECOME THE CHAMPION!!! ") ;
printf("\n\t\t________________________________________");
printf("\n\t\t________________________________________");
printf("\n\t\t > Press S to start the game");
printf("\n\t\t > press H for help ");
printf("\n\t\t > press Q to quit ");
printf("\n\t\t________________________________________\n\n");


printf("\n\n\tAnswers must all begin with an uppercase letter\n\n\n");
//MAIN MENU SELECTION OPTIONS
choice=toupper(getchar());
printf("you entered %c\n",choice);

if (toupper(getchar())=='S')
goto home;
else if (choice=='H'){
printf("you typed in H");
help();
getchar();
goto mainhome;
}
else if (choice=='Q'){
printf("you typed in Q");
exit(1);

}


home:
//HAVING QUESTIONS PRINT ONE AT A TIME
for (e=0; e < num_ques; e++) //loop to go through each question in text file
{
//printf("\nQuestion:");
printf("\n***Type in your answer to the following question:\n\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL)
{
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c

if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL)
{
fprintf(stderr,"Error while reading file\n");
return -1;
}



for (i=0; i < 1; i++)
{
// printf("%d\n",i);
//fprintf(stderr,"DIAGNOSTIC -- the answer: %s\n", ans_arr);
//printf("DIAGNOSTIC -- GUESS variable is:%s\n", guess);
fgets(guess, sizeof(guess), stdin);

//fprintf(stderr,"you answered %s\n",guess);

if (strcmp(ans_arr, guess) == 0)
{
printf("Your guess was correct\n\n");
countr++;
}
else if (guess!=ans_arr)
{
printf("Your guess was incorrect.\n");
printf("The answer was: %s\n\n\n\n", ans_arr);
}
else
{
printf("You ran out of questions.");
}
}
}


fclose(questions);
fclose(answers);

//SHOWING THE CONTESTANT THEIR SCORE - HOW MANY QUESTIONS THEY GOT CORRECT
score:
system("clear");
//score=countr;
//printf("* DIAGNOSTIC -- countr is %d\n",countr);
//printf("* DIAGNOSTIC -- score is %d\n",score);
if(countr>0 && countr<=29){
printf("\n\n\t\t************* CONGRATULATIONS **************");
printf("\n\t\t\t You won %d points! \n", countr);
}

else if(countr==30){ //highest score possible
printf("\n\n\n \t\t*********** Nice Job!! ***********");
printf("\n\t\t\t\t You are the champion!!!!!!!!!");
printf("\n\t\t\t You won %d points! \n",countr);
printf("\t\t Thank You!!");
}
else{
printf("\n\n\t******** You did not win any points ********");
printf("\n\t\t Thanks for playing!. \n");
printf("\n\t\t Better luck next time! \n");
}



return 0;


}
30 changes: 30 additions & 0 deletions FinalProject/readme.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
Ava N.
July 15, 2016
Ava's Quiz Game

This is a quiz show game programmed in C during Columbia HSP. My project takes questions from 'questions.txt' and answers from 'answer.txt' to these questions. There is a 'help' center, a 'quit' command, and a command to start the game. All instructions of how to play the game are inside of the game. This is a one player game.


In my proposal, I mentioned including a timer; however, I decided in the end not to add one. I also stated in my introduction that I would have different slots for different categories with different point systems. I later decided that I would not have different categories but a list of questions that players of 'Ava's Quiz Game' would need to answer. Although I did not have time to include graphics, I created a fun looking 'main menu'!

All of the answers to the questions, if you want to beat the game, are in answer.txt .


I got my idea of how to set up Ava's Quiz Show here: http://www.codewithc.com/quiz-game-mini-project-in-c/



Files used in Ava's Quiz Show: [quiz_game.c], [questions.txt], and [answers.txt]. All other files in Final Code folder were used to test the code in the main file.


I hope you enjoy Ava's Quiz Show!



compile statement:
gcc quiz_game.c -o quiz_game
./quiz_game




Binary file addedFinalProject/sam
Binary file not shown.
59 changes: 59 additions & 0 deletions FinalProject/sample_doc.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
//This is for checking the code of the question-answer section in quiz_game code

#include <stdio.h>
#include <string.h>

int main (void){
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[25]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i;
int e;
const int num_ques=5;
for (e=0; e < num_ques; e++){

printf("Type in your answer to the following question:\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL){ //read 1 line from file
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c
if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL){
fprintf(stderr,"Error while reading file\n");
return -1;
}

for (i=0; i < 1; i++){ //Loop for questions asking
//printf("%d\n",i);
//fprintf(stderr,"the answer: %s\n", ans_arr);
//printf("Please guess the word: \n");
fgets(guess, sizeof(guess), stdin);

fprintf(stderr,"you answered %s\n",guess);
if (strcmp(ans_arr, guess) == 0){
printf("Your guess was correct\n\n");
//continue;
}
else if (guess!=ans_arr){
printf("Your guess was incorrect.\n\n\n");
//continue;
}
else {
printf("You ran out of questions");
//break;
}
}
}


fclose(questions);
fclose(answers);
return 0;
}


Binary file addedFinalProject/temp
Binary file not shown.
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions AvaFinalProject.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
Ava N.
July 9, 2016

Final Project Proposal:

For my final project, I would like to create a quiz show, similar to Jeopardy. The objective of the game is to answer as many questions correctly as possible. I will be adding a time limit as well.

The questions would be divided into different categories. For example, under the "computer science" category, the lowest, or '100' slot question might state: 'This device was used to solve math problems before the invention of electricity." The answer, which would not be case sensitive, would be inputed by the contestant/player. Also, I am deciding whether to require the player input to include "what is ..." before the answer. This game will be created for a single-player, but if I have time, I would like to make a 2, 3, or 4 player option as well.

An example of a loop I would use is for the fill-in the answer section. If the correct answer is chosen, then the point goes to the player who asked the question (under a time limit). If that person does not answer correctly or under the time limit, it will go to the next player, and if that player answers correctly, then the original amount of points will get split in half. I will also use functions for the input of the contestant.

I am choosing this project because taking part in a quiz show or game is so much fun, and playing one that I create would be great. I am excited to develop the game design and decide how I will arrange the 'answers' and the 'questions', and where I will put the timer, and arrange different color schemes.

Libraries I will use are the include the ones we have used in class: stdio.h, string.h, math.h, etc. I plan to use the time.h library for the timer. For graphics, I may want to use Cairo, although I have never used that library before.

This is my Final Project Proposal and I am excited to start working on it (once it is approved)!
30 changes: 30 additions & 0 deletions FinalProject/answer.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
Army
Switzerland
Hyena
New York City
Mudd
Winter
700
February
Bonjour
Whale
1492
Abacus
Orange
P
Hydrogen
24
Nile River
Mount Everest
Elvis Presley
Damascus
Sicily
Venezuela
Retriever
1984
Theodore Roosevelt
6
1509
Queue
Ada Lovelace
Yes
1 change: 1 addition & 0 deletions FinalProject/extra.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@

30 changes: 30 additions & 0 deletions FinalProject/questions.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1. What is a group of frogs known as?
2. What country has the highest environmental performance index?
3. Which animal laughs like human being?
4. In which city is manhattan located?
5. In which building is the Columbia HSP for Intro to Programming in C?
6. During what season do animals hybernate?
7. How much wood would a woodchuck chuck if a woodchuck could chuck wood (answer in pounds)?
8. In what month is Valentine's Day?
9. How do you say 'Hello/Good morning' in french?
10. Which underwater creature is bigger: Dolphin or Whale?
11. In what year did Christopher Columbus sail the ocean blue?
12. What device was used to solve math problems before the invention of electricity?
13. What color comes after red in the rainbow?
14. What is the 16th letter in the alphabet?
15. What is the first element in the periodic table (not in scientific notation)?
16. How many students are in the Introduction to Programming in C class?
17. What is the longest river in the world? (include 'River' at the end of answer)
18. What is the highest mountain in the world?
19. Who is known for being the King of Rock 'n Roll?
20. What is the world's oldest city?
21. What is the largest island in the Mediterranean sea?
22. In what country is the highest waterfall in the world?
23. What is the most popoular breed of dog?
24. In which year was the first computer sold with a mouse?
25. Who was the youngest President in the United States?
26. How many legs do butterflies have?
27. In which year did Henry VIII become King of England?
28. What is a linear data structure in which elements are added on one end and removed from the other?
29. Which female mathematician developed the first algorithm for the Analytical Machine?
30. Did you enjoy playing? (Yes/No)
Binary file addedFinalProject/quiz_game
Binary file not shown.
170 changes: 170 additions & 0 deletions FinalProject/quiz_game.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
//Ava N.'s

//REAL VERSION -- Ava's Quiz Show
//Columbia HSP FInal Project
//Intro to Programming in C
//Due: July 15, 2016

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>


void help(){ //gives instructions of the game
system("clear");
printf("\n\n Instructions:");
printf("\n ------------------------------------------------------");
printf("\n ................... Ava's Quiz Show ....................");
printf("\n >> You have to be able to answer 30 questions correctly.");
printf("\n >> All of the questions require fill-in answers.");
printf("\n >> This game is case-sensitive, so all answers have to");
printf("\n have the first letter of each word uppercase.");
printf("\n >> If the question asks for a number, answer with a number.");
printf("\n >> The maximum number of points a you can get is 11.");

printf("\n >> You will not be penalized for incorrect answers.");

printf("\n\n\t**************Good Luck*******************\n\n");
printf("\n\n\t Press 'enter' to continue to the main menu\n");
}



//start of the game show
int main(void){

system("clear");
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[100]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i; //variable for loop that checks contestants answers
int e; //variable for going through the questions.txt file
const int num_ques=29; //includes number of questions
char choice; //main menu variable
int countr = 0; //score

mainhome:
system("clear"); //source: http://stackoverflow.com/questions/15102976/how-to-clear-screen-from-simple-c-program
//printf("\t\t\tC PROGRAM QUIZ GAME\n");
printf("\n\t\t________________________________________");

printf("\n\t\t\t * WELCOME *");
printf("\n\t\t\t * to *");
printf("\n\t\t\t * AVA'S GAME SHOW *");
printf("\n\t\t ____*_*_*_*_*_*_*_*_*_*_*_*____");
printf("\n\t\t________________________________________");
printf("\n\t\t\t BECOME THE CHAMPION!!! ") ;
printf("\n\t\t________________________________________");
printf("\n\t\t________________________________________");
printf("\n\t\t > Press S to start the game");
printf("\n\t\t > press H for help ");
printf("\n\t\t > press Q to quit ");
printf("\n\t\t________________________________________\n\n");


printf("\n\n\tAnswers must all begin with an uppercase letter\n\n\n");
//MAIN MENU SELECTION OPTIONS
choice=toupper(getchar());
printf("you entered %c\n",choice);

if (toupper(getchar())=='S')
goto home;
else if (choice=='H'){
printf("you typed in H");
help();
getchar();
goto mainhome;
}
else if (choice=='Q'){
printf("you typed in Q");
exit(1);

}


home:
//HAVING QUESTIONS PRINT ONE AT A TIME
for (e=0; e < num_ques; e++) //loop to go through each question in text file
{
//printf("\nQuestion:");
printf("\n***Type in your answer to the following question:\n\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL)
{
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c

if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL)
{
fprintf(stderr,"Error while reading file\n");
return -1;
}



for (i=0; i < 1; i++)
{
// printf("%d\n",i);
//fprintf(stderr,"DIAGNOSTIC -- the answer: %s\n", ans_arr);
//printf("DIAGNOSTIC -- GUESS variable is:%s\n", guess);
fgets(guess, sizeof(guess), stdin);

//fprintf(stderr,"you answered %s\n",guess);

if (strcmp(ans_arr, guess) == 0)
{
printf("Your guess was correct\n\n");
countr++;
}
else if (guess!=ans_arr)
{
printf("Your guess was incorrect.\n");
printf("The answer was: %s\n\n\n\n", ans_arr);
}
else
{
printf("You ran out of questions.");
}
}
}


fclose(questions);
fclose(answers);

//SHOWING THE CONTESTANT THEIR SCORE - HOW MANY QUESTIONS THEY GOT CORRECT
score:
system("clear");
//score=countr;
//printf("* DIAGNOSTIC -- countr is %d\n",countr);
//printf("* DIAGNOSTIC -- score is %d\n",score);
if(countr>0 && countr<=29){
printf("\n\n\t\t************* CONGRATULATIONS **************");
printf("\n\t\t\t You won %d points! \n", countr);
}

else if(countr==30){ //highest score possible
printf("\n\n\n \t\t*********** Nice Job!! ***********");
printf("\n\t\t\t\t You are the champion!!!!!!!!!");
printf("\n\t\t\t You won %d points! \n",countr);
printf("\t\t Thank You!!");
}
else{
printf("\n\n\t******** You did not win any points ********");
printf("\n\t\t Thanks for playing!. \n");
printf("\n\t\t Better luck next time! \n");
}



return 0;


}
30 changes: 30 additions & 0 deletions FinalProject/readme.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
Ava N.
July 15, 2016
Ava's Quiz Game

This is a quiz show game programmed in C during Columbia HSP. My project takes questions from 'questions.txt' and answers from 'answer.txt' to these questions. There is a 'help' center, a 'quit' command, and a command to start the game. All instructions of how to play the game are inside of the game. This is a one player game.


In my proposal, I mentioned including a timer; however, I decided in the end not to add one. I also stated in my introduction that I would have different slots for different categories with different point systems. I later decided that I would not have different categories but a list of questions that players of 'Ava's Quiz Game' would need to answer. Although I did not have time to include graphics, I created a fun looking 'main menu'!

All of the answers to the questions, if you want to beat the game, are in answer.txt .


I got my idea of how to set up Ava's Quiz Show here: http://www.codewithc.com/quiz-game-mini-project-in-c/



Files used in Ava's Quiz Show: [quiz_game.c], [questions.txt], and [answers.txt]. All other files in Final Code folder were used to test the code in the main file.


I hope you enjoy Ava's Quiz Show!



compile statement:
gcc quiz_game.c -o quiz_game
./quiz_game




Binary file addedFinalProject/sam
Binary file not shown.
59 changes: 59 additions & 0 deletions FinalProject/sample_doc.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
//This is for checking the code of the question-answer section in quiz_game code

#include <stdio.h>
#include <string.h>

int main (void){
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[25]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i;
int e;
const int num_ques=5;
for (e=0; e < num_ques; e++){

printf("Type in your answer to the following question:\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL){ //read 1 line from file
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c
if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL){
fprintf(stderr,"Error while reading file\n");
return -1;
}

for (i=0; i < 1; i++){ //Loop for questions asking
//printf("%d\n",i);
//fprintf(stderr,"the answer: %s\n", ans_arr);
//printf("Please guess the word: \n");
fgets(guess, sizeof(guess), stdin);

fprintf(stderr,"you answered %s\n",guess);
if (strcmp(ans_arr, guess) == 0){
printf("Your guess was correct\n\n");
//continue;
}
else if (guess!=ans_arr){
printf("Your guess was incorrect.\n\n\n");
//continue;
}
else {
printf("You ran out of questions");
//break;
}
}
}


fclose(questions);
fclose(answers);
return 0;
}


Binary file addedFinalProject/temp
Binary file not shown.
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions AvaFinalProject.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
Ava N.
July 9, 2016

Final Project Proposal:

For my final project, I would like to create a quiz show, similar to Jeopardy. The objective of the game is to answer as many questions correctly as possible. I will be adding a time limit as well.

The questions would be divided into different categories. For example, under the "computer science" category, the lowest, or '100' slot question might state: 'This device was used to solve math problems before the invention of electricity." The answer, which would not be case sensitive, would be inputed by the contestant/player. Also, I am deciding whether to require the player input to include "what is ..." before the answer. This game will be created for a single-player, but if I have time, I would like to make a 2, 3, or 4 player option as well.

An example of a loop I would use is for the fill-in the answer section. If the correct answer is chosen, then the point goes to the player who asked the question (under a time limit). If that person does not answer correctly or under the time limit, it will go to the next player, and if that player answers correctly, then the original amount of points will get split in half. I will also use functions for the input of the contestant.

I am choosing this project because taking part in a quiz show or game is so much fun, and playing one that I create would be great. I am excited to develop the game design and decide how I will arrange the 'answers' and the 'questions', and where I will put the timer, and arrange different color schemes.

Libraries I will use are the include the ones we have used in class: stdio.h, string.h, math.h, etc. I plan to use the time.h library for the timer. For graphics, I may want to use Cairo, although I have never used that library before.

This is my Final Project Proposal and I am excited to start working on it (once it is approved)!
30 changes: 30 additions & 0 deletions FinalProject/answer.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
Army
Switzerland
Hyena
New York City
Mudd
Winter
700
February
Bonjour
Whale
1492
Abacus
Orange
P
Hydrogen
24
Nile River
Mount Everest
Elvis Presley
Damascus
Sicily
Venezuela
Retriever
1984
Theodore Roosevelt
6
1509
Queue
Ada Lovelace
Yes
1 change: 1 addition & 0 deletions FinalProject/extra.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@

30 changes: 30 additions & 0 deletions FinalProject/questions.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1. What is a group of frogs known as?
2. What country has the highest environmental performance index?
3. Which animal laughs like human being?
4. In which city is manhattan located?
5. In which building is the Columbia HSP for Intro to Programming in C?
6. During what season do animals hybernate?
7. How much wood would a woodchuck chuck if a woodchuck could chuck wood (answer in pounds)?
8. In what month is Valentine's Day?
9. How do you say 'Hello/Good morning' in french?
10. Which underwater creature is bigger: Dolphin or Whale?
11. In what year did Christopher Columbus sail the ocean blue?
12. What device was used to solve math problems before the invention of electricity?
13. What color comes after red in the rainbow?
14. What is the 16th letter in the alphabet?
15. What is the first element in the periodic table (not in scientific notation)?
16. How many students are in the Introduction to Programming in C class?
17. What is the longest river in the world? (include 'River' at the end of answer)
18. What is the highest mountain in the world?
19. Who is known for being the King of Rock 'n Roll?
20. What is the world's oldest city?
21. What is the largest island in the Mediterranean sea?
22. In what country is the highest waterfall in the world?
23. What is the most popoular breed of dog?
24. In which year was the first computer sold with a mouse?
25. Who was the youngest President in the United States?
26. How many legs do butterflies have?
27. In which year did Henry VIII become King of England?
28. What is a linear data structure in which elements are added on one end and removed from the other?
29. Which female mathematician developed the first algorithm for the Analytical Machine?
30. Did you enjoy playing? (Yes/No)
Binary file addedFinalProject/quiz_game
Binary file not shown.
170 changes: 170 additions & 0 deletions FinalProject/quiz_game.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
//Ava N.'s

//REAL VERSION -- Ava's Quiz Show
//Columbia HSP FInal Project
//Intro to Programming in C
//Due: July 15, 2016

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>


void help(){ //gives instructions of the game
system("clear");
printf("\n\n Instructions:");
printf("\n ------------------------------------------------------");
printf("\n ................... Ava's Quiz Show ....................");
printf("\n >> You have to be able to answer 30 questions correctly.");
printf("\n >> All of the questions require fill-in answers.");
printf("\n >> This game is case-sensitive, so all answers have to");
printf("\n have the first letter of each word uppercase.");
printf("\n >> If the question asks for a number, answer with a number.");
printf("\n >> The maximum number of points a you can get is 11.");

printf("\n >> You will not be penalized for incorrect answers.");

printf("\n\n\t**************Good Luck*******************\n\n");
printf("\n\n\t Press 'enter' to continue to the main menu\n");
}



//start of the game show
int main(void){

system("clear");
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[100]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i; //variable for loop that checks contestants answers
int e; //variable for going through the questions.txt file
const int num_ques=29; //includes number of questions
char choice; //main menu variable
int countr = 0; //score

mainhome:
system("clear"); //source: http://stackoverflow.com/questions/15102976/how-to-clear-screen-from-simple-c-program
//printf("\t\t\tC PROGRAM QUIZ GAME\n");
printf("\n\t\t________________________________________");

printf("\n\t\t\t * WELCOME *");
printf("\n\t\t\t * to *");
printf("\n\t\t\t * AVA'S GAME SHOW *");
printf("\n\t\t ____*_*_*_*_*_*_*_*_*_*_*_*____");
printf("\n\t\t________________________________________");
printf("\n\t\t\t BECOME THE CHAMPION!!! ") ;
printf("\n\t\t________________________________________");
printf("\n\t\t________________________________________");
printf("\n\t\t > Press S to start the game");
printf("\n\t\t > press H for help ");
printf("\n\t\t > press Q to quit ");
printf("\n\t\t________________________________________\n\n");


printf("\n\n\tAnswers must all begin with an uppercase letter\n\n\n");
//MAIN MENU SELECTION OPTIONS
choice=toupper(getchar());
printf("you entered %c\n",choice);

if (toupper(getchar())=='S')
goto home;
else if (choice=='H'){
printf("you typed in H");
help();
getchar();
goto mainhome;
}
else if (choice=='Q'){
printf("you typed in Q");
exit(1);

}


home:
//HAVING QUESTIONS PRINT ONE AT A TIME
for (e=0; e < num_ques; e++) //loop to go through each question in text file
{
//printf("\nQuestion:");
printf("\n***Type in your answer to the following question:\n\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL)
{
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c

if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL)
{
fprintf(stderr,"Error while reading file\n");
return -1;
}



for (i=0; i < 1; i++)
{
// printf("%d\n",i);
//fprintf(stderr,"DIAGNOSTIC -- the answer: %s\n", ans_arr);
//printf("DIAGNOSTIC -- GUESS variable is:%s\n", guess);
fgets(guess, sizeof(guess), stdin);

//fprintf(stderr,"you answered %s\n",guess);

if (strcmp(ans_arr, guess) == 0)
{
printf("Your guess was correct\n\n");
countr++;
}
else if (guess!=ans_arr)
{
printf("Your guess was incorrect.\n");
printf("The answer was: %s\n\n\n\n", ans_arr);
}
else
{
printf("You ran out of questions.");
}
}
}


fclose(questions);
fclose(answers);

//SHOWING THE CONTESTANT THEIR SCORE - HOW MANY QUESTIONS THEY GOT CORRECT
score:
system("clear");
//score=countr;
//printf("* DIAGNOSTIC -- countr is %d\n",countr);
//printf("* DIAGNOSTIC -- score is %d\n",score);
if(countr>0 && countr<=29){
printf("\n\n\t\t************* CONGRATULATIONS **************");
printf("\n\t\t\t You won %d points! \n", countr);
}

else if(countr==30){ //highest score possible
printf("\n\n\n \t\t*********** Nice Job!! ***********");
printf("\n\t\t\t\t You are the champion!!!!!!!!!");
printf("\n\t\t\t You won %d points! \n",countr);
printf("\t\t Thank You!!");
}
else{
printf("\n\n\t******** You did not win any points ********");
printf("\n\t\t Thanks for playing!. \n");
printf("\n\t\t Better luck next time! \n");
}



return 0;


}
30 changes: 30 additions & 0 deletions FinalProject/readme.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
Ava N.
July 15, 2016
Ava's Quiz Game

This is a quiz show game programmed in C during Columbia HSP. My project takes questions from 'questions.txt' and answers from 'answer.txt' to these questions. There is a 'help' center, a 'quit' command, and a command to start the game. All instructions of how to play the game are inside of the game. This is a one player game.


In my proposal, I mentioned including a timer; however, I decided in the end not to add one. I also stated in my introduction that I would have different slots for different categories with different point systems. I later decided that I would not have different categories but a list of questions that players of 'Ava's Quiz Game' would need to answer. Although I did not have time to include graphics, I created a fun looking 'main menu'!

All of the answers to the questions, if you want to beat the game, are in answer.txt .


I got my idea of how to set up Ava's Quiz Show here: http://www.codewithc.com/quiz-game-mini-project-in-c/



Files used in Ava's Quiz Show: [quiz_game.c], [questions.txt], and [answers.txt]. All other files in Final Code folder were used to test the code in the main file.


I hope you enjoy Ava's Quiz Show!



compile statement:
gcc quiz_game.c -o quiz_game
./quiz_game




Binary file addedFinalProject/sam
Binary file not shown.
59 changes: 59 additions & 0 deletions FinalProject/sample_doc.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
//This is for checking the code of the question-answer section in quiz_game code

#include <stdio.h>
#include <string.h>

int main (void){
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[25]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i;
int e;
const int num_ques=5;
for (e=0; e < num_ques; e++){

printf("Type in your answer to the following question:\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL){ //read 1 line from file
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c
if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL){
fprintf(stderr,"Error while reading file\n");
return -1;
}

for (i=0; i < 1; i++){ //Loop for questions asking
//printf("%d\n",i);
//fprintf(stderr,"the answer: %s\n", ans_arr);
//printf("Please guess the word: \n");
fgets(guess, sizeof(guess), stdin);

fprintf(stderr,"you answered %s\n",guess);
if (strcmp(ans_arr, guess) == 0){
printf("Your guess was correct\n\n");
//continue;
}
else if (guess!=ans_arr){
printf("Your guess was incorrect.\n\n\n");
//continue;
}
else {
printf("You ran out of questions");
//break;
}
}
}


fclose(questions);
fclose(answers);
return 0;
}


Binary file addedFinalProject/temp
Binary file not shown.
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions AvaFinalProject.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
Ava N.
July 9, 2016

Final Project Proposal:

For my final project, I would like to create a quiz show, similar to Jeopardy. The objective of the game is to answer as many questions correctly as possible. I will be adding a time limit as well.

The questions would be divided into different categories. For example, under the "computer science" category, the lowest, or '100' slot question might state: 'This device was used to solve math problems before the invention of electricity." The answer, which would not be case sensitive, would be inputed by the contestant/player. Also, I am deciding whether to require the player input to include "what is ..." before the answer. This game will be created for a single-player, but if I have time, I would like to make a 2, 3, or 4 player option as well.

An example of a loop I would use is for the fill-in the answer section. If the correct answer is chosen, then the point goes to the player who asked the question (under a time limit). If that person does not answer correctly or under the time limit, it will go to the next player, and if that player answers correctly, then the original amount of points will get split in half. I will also use functions for the input of the contestant.

I am choosing this project because taking part in a quiz show or game is so much fun, and playing one that I create would be great. I am excited to develop the game design and decide how I will arrange the 'answers' and the 'questions', and where I will put the timer, and arrange different color schemes.

Libraries I will use are the include the ones we have used in class: stdio.h, string.h, math.h, etc. I plan to use the time.h library for the timer. For graphics, I may want to use Cairo, although I have never used that library before.

This is my Final Project Proposal and I am excited to start working on it (once it is approved)!
30 changes: 30 additions & 0 deletions FinalProject/answer.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
Army
Switzerland
Hyena
New York City
Mudd
Winter
700
February
Bonjour
Whale
1492
Abacus
Orange
P
Hydrogen
24
Nile River
Mount Everest
Elvis Presley
Damascus
Sicily
Venezuela
Retriever
1984
Theodore Roosevelt
6
1509
Queue
Ada Lovelace
Yes
1 change: 1 addition & 0 deletions FinalProject/extra.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@

30 changes: 30 additions & 0 deletions FinalProject/questions.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1. What is a group of frogs known as?
2. What country has the highest environmental performance index?
3. Which animal laughs like human being?
4. In which city is manhattan located?
5. In which building is the Columbia HSP for Intro to Programming in C?
6. During what season do animals hybernate?
7. How much wood would a woodchuck chuck if a woodchuck could chuck wood (answer in pounds)?
8. In what month is Valentine's Day?
9. How do you say 'Hello/Good morning' in french?
10. Which underwater creature is bigger: Dolphin or Whale?
11. In what year did Christopher Columbus sail the ocean blue?
12. What device was used to solve math problems before the invention of electricity?
13. What color comes after red in the rainbow?
14. What is the 16th letter in the alphabet?
15. What is the first element in the periodic table (not in scientific notation)?
16. How many students are in the Introduction to Programming in C class?
17. What is the longest river in the world? (include 'River' at the end of answer)
18. What is the highest mountain in the world?
19. Who is known for being the King of Rock 'n Roll?
20. What is the world's oldest city?
21. What is the largest island in the Mediterranean sea?
22. In what country is the highest waterfall in the world?
23. What is the most popoular breed of dog?
24. In which year was the first computer sold with a mouse?
25. Who was the youngest President in the United States?
26. How many legs do butterflies have?
27. In which year did Henry VIII become King of England?
28. What is a linear data structure in which elements are added on one end and removed from the other?
29. Which female mathematician developed the first algorithm for the Analytical Machine?
30. Did you enjoy playing? (Yes/No)
Binary file addedFinalProject/quiz_game
Binary file not shown.
170 changes: 170 additions & 0 deletions FinalProject/quiz_game.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
//Ava N.'s

//REAL VERSION -- Ava's Quiz Show
//Columbia HSP FInal Project
//Intro to Programming in C
//Due: July 15, 2016

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>


void help(){ //gives instructions of the game
system("clear");
printf("\n\n Instructions:");
printf("\n ------------------------------------------------------");
printf("\n ................... Ava's Quiz Show ....................");
printf("\n >> You have to be able to answer 30 questions correctly.");
printf("\n >> All of the questions require fill-in answers.");
printf("\n >> This game is case-sensitive, so all answers have to");
printf("\n have the first letter of each word uppercase.");
printf("\n >> If the question asks for a number, answer with a number.");
printf("\n >> The maximum number of points a you can get is 11.");

printf("\n >> You will not be penalized for incorrect answers.");

printf("\n\n\t**************Good Luck*******************\n\n");
printf("\n\n\t Press 'enter' to continue to the main menu\n");
}



//start of the game show
int main(void){

system("clear");
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[100]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i; //variable for loop that checks contestants answers
int e; //variable for going through the questions.txt file
const int num_ques=29; //includes number of questions
char choice; //main menu variable
int countr = 0; //score

mainhome:
system("clear"); //source: http://stackoverflow.com/questions/15102976/how-to-clear-screen-from-simple-c-program
//printf("\t\t\tC PROGRAM QUIZ GAME\n");
printf("\n\t\t________________________________________");

printf("\n\t\t\t * WELCOME *");
printf("\n\t\t\t * to *");
printf("\n\t\t\t * AVA'S GAME SHOW *");
printf("\n\t\t ____*_*_*_*_*_*_*_*_*_*_*_*____");
printf("\n\t\t________________________________________");
printf("\n\t\t\t BECOME THE CHAMPION!!! ") ;
printf("\n\t\t________________________________________");
printf("\n\t\t________________________________________");
printf("\n\t\t > Press S to start the game");
printf("\n\t\t > press H for help ");
printf("\n\t\t > press Q to quit ");
printf("\n\t\t________________________________________\n\n");


printf("\n\n\tAnswers must all begin with an uppercase letter\n\n\n");
//MAIN MENU SELECTION OPTIONS
choice=toupper(getchar());
printf("you entered %c\n",choice);

if (toupper(getchar())=='S')
goto home;
else if (choice=='H'){
printf("you typed in H");
help();
getchar();
goto mainhome;
}
else if (choice=='Q'){
printf("you typed in Q");
exit(1);

}


home:
//HAVING QUESTIONS PRINT ONE AT A TIME
for (e=0; e < num_ques; e++) //loop to go through each question in text file
{
//printf("\nQuestion:");
printf("\n***Type in your answer to the following question:\n\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL)
{
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c

if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL)
{
fprintf(stderr,"Error while reading file\n");
return -1;
}



for (i=0; i < 1; i++)
{
// printf("%d\n",i);
//fprintf(stderr,"DIAGNOSTIC -- the answer: %s\n", ans_arr);
//printf("DIAGNOSTIC -- GUESS variable is:%s\n", guess);
fgets(guess, sizeof(guess), stdin);

//fprintf(stderr,"you answered %s\n",guess);

if (strcmp(ans_arr, guess) == 0)
{
printf("Your guess was correct\n\n");
countr++;
}
else if (guess!=ans_arr)
{
printf("Your guess was incorrect.\n");
printf("The answer was: %s\n\n\n\n", ans_arr);
}
else
{
printf("You ran out of questions.");
}
}
}


fclose(questions);
fclose(answers);

//SHOWING THE CONTESTANT THEIR SCORE - HOW MANY QUESTIONS THEY GOT CORRECT
score:
system("clear");
//score=countr;
//printf("* DIAGNOSTIC -- countr is %d\n",countr);
//printf("* DIAGNOSTIC -- score is %d\n",score);
if(countr>0 && countr<=29){
printf("\n\n\t\t************* CONGRATULATIONS **************");
printf("\n\t\t\t You won %d points! \n", countr);
}

else if(countr==30){ //highest score possible
printf("\n\n\n \t\t*********** Nice Job!! ***********");
printf("\n\t\t\t\t You are the champion!!!!!!!!!");
printf("\n\t\t\t You won %d points! \n",countr);
printf("\t\t Thank You!!");
}
else{
printf("\n\n\t******** You did not win any points ********");
printf("\n\t\t Thanks for playing!. \n");
printf("\n\t\t Better luck next time! \n");
}



return 0;


}
30 changes: 30 additions & 0 deletions FinalProject/readme.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
Ava N.
July 15, 2016
Ava's Quiz Game

This is a quiz show game programmed in C during Columbia HSP. My project takes questions from 'questions.txt' and answers from 'answer.txt' to these questions. There is a 'help' center, a 'quit' command, and a command to start the game. All instructions of how to play the game are inside of the game. This is a one player game.


In my proposal, I mentioned including a timer; however, I decided in the end not to add one. I also stated in my introduction that I would have different slots for different categories with different point systems. I later decided that I would not have different categories but a list of questions that players of 'Ava's Quiz Game' would need to answer. Although I did not have time to include graphics, I created a fun looking 'main menu'!

All of the answers to the questions, if you want to beat the game, are in answer.txt .


I got my idea of how to set up Ava's Quiz Show here: http://www.codewithc.com/quiz-game-mini-project-in-c/



Files used in Ava's Quiz Show: [quiz_game.c], [questions.txt], and [answers.txt]. All other files in Final Code folder were used to test the code in the main file.


I hope you enjoy Ava's Quiz Show!



compile statement:
gcc quiz_game.c -o quiz_game
./quiz_game




Binary file addedFinalProject/sam
Binary file not shown.
59 changes: 59 additions & 0 deletions FinalProject/sample_doc.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
//This is for checking the code of the question-answer section in quiz_game code

#include <stdio.h>
#include <string.h>

int main (void){
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[25]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i;
int e;
const int num_ques=5;
for (e=0; e < num_ques; e++){

printf("Type in your answer to the following question:\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL){ //read 1 line from file
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c
if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL){
fprintf(stderr,"Error while reading file\n");
return -1;
}

for (i=0; i < 1; i++){ //Loop for questions asking
//printf("%d\n",i);
//fprintf(stderr,"the answer: %s\n", ans_arr);
//printf("Please guess the word: \n");
fgets(guess, sizeof(guess), stdin);

fprintf(stderr,"you answered %s\n",guess);
if (strcmp(ans_arr, guess) == 0){
printf("Your guess was correct\n\n");
//continue;
}
else if (guess!=ans_arr){
printf("Your guess was incorrect.\n\n\n");
//continue;
}
else {
printf("You ran out of questions");
//break;
}
}
}


fclose(questions);
fclose(answers);
return 0;
}


Binary file addedFinalProject/temp
Binary file not shown.
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions AvaFinalProject.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
Ava N.
July 9, 2016

Final Project Proposal:

For my final project, I would like to create a quiz show, similar to Jeopardy. The objective of the game is to answer as many questions correctly as possible. I will be adding a time limit as well.

The questions would be divided into different categories. For example, under the "computer science" category, the lowest, or '100' slot question might state: 'This device was used to solve math problems before the invention of electricity." The answer, which would not be case sensitive, would be inputed by the contestant/player. Also, I am deciding whether to require the player input to include "what is ..." before the answer. This game will be created for a single-player, but if I have time, I would like to make a 2, 3, or 4 player option as well.

An example of a loop I would use is for the fill-in the answer section. If the correct answer is chosen, then the point goes to the player who asked the question (under a time limit). If that person does not answer correctly or under the time limit, it will go to the next player, and if that player answers correctly, then the original amount of points will get split in half. I will also use functions for the input of the contestant.

I am choosing this project because taking part in a quiz show or game is so much fun, and playing one that I create would be great. I am excited to develop the game design and decide how I will arrange the 'answers' and the 'questions', and where I will put the timer, and arrange different color schemes.

Libraries I will use are the include the ones we have used in class: stdio.h, string.h, math.h, etc. I plan to use the time.h library for the timer. For graphics, I may want to use Cairo, although I have never used that library before.

This is my Final Project Proposal and I am excited to start working on it (once it is approved)!
30 changes: 30 additions & 0 deletions FinalProject/answer.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
Army
Switzerland
Hyena
New York City
Mudd
Winter
700
February
Bonjour
Whale
1492
Abacus
Orange
P
Hydrogen
24
Nile River
Mount Everest
Elvis Presley
Damascus
Sicily
Venezuela
Retriever
1984
Theodore Roosevelt
6
1509
Queue
Ada Lovelace
Yes
1 change: 1 addition & 0 deletions FinalProject/extra.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@

30 changes: 30 additions & 0 deletions FinalProject/questions.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1. What is a group of frogs known as?
2. What country has the highest environmental performance index?
3. Which animal laughs like human being?
4. In which city is manhattan located?
5. In which building is the Columbia HSP for Intro to Programming in C?
6. During what season do animals hybernate?
7. How much wood would a woodchuck chuck if a woodchuck could chuck wood (answer in pounds)?
8. In what month is Valentine's Day?
9. How do you say 'Hello/Good morning' in french?
10. Which underwater creature is bigger: Dolphin or Whale?
11. In what year did Christopher Columbus sail the ocean blue?
12. What device was used to solve math problems before the invention of electricity?
13. What color comes after red in the rainbow?
14. What is the 16th letter in the alphabet?
15. What is the first element in the periodic table (not in scientific notation)?
16. How many students are in the Introduction to Programming in C class?
17. What is the longest river in the world? (include 'River' at the end of answer)
18. What is the highest mountain in the world?
19. Who is known for being the King of Rock 'n Roll?
20. What is the world's oldest city?
21. What is the largest island in the Mediterranean sea?
22. In what country is the highest waterfall in the world?
23. What is the most popoular breed of dog?
24. In which year was the first computer sold with a mouse?
25. Who was the youngest President in the United States?
26. How many legs do butterflies have?
27. In which year did Henry VIII become King of England?
28. What is a linear data structure in which elements are added on one end and removed from the other?
29. Which female mathematician developed the first algorithm for the Analytical Machine?
30. Did you enjoy playing? (Yes/No)
Binary file addedFinalProject/quiz_game
Binary file not shown.
170 changes: 170 additions & 0 deletions FinalProject/quiz_game.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
//Ava N.'s

//REAL VERSION -- Ava's Quiz Show
//Columbia HSP FInal Project
//Intro to Programming in C
//Due: July 15, 2016

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>


void help(){ //gives instructions of the game
system("clear");
printf("\n\n Instructions:");
printf("\n ------------------------------------------------------");
printf("\n ................... Ava's Quiz Show ....................");
printf("\n >> You have to be able to answer 30 questions correctly.");
printf("\n >> All of the questions require fill-in answers.");
printf("\n >> This game is case-sensitive, so all answers have to");
printf("\n have the first letter of each word uppercase.");
printf("\n >> If the question asks for a number, answer with a number.");
printf("\n >> The maximum number of points a you can get is 11.");

printf("\n >> You will not be penalized for incorrect answers.");

printf("\n\n\t**************Good Luck*******************\n\n");
printf("\n\n\t Press 'enter' to continue to the main menu\n");
}



//start of the game show
int main(void){

system("clear");
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[100]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i; //variable for loop that checks contestants answers
int e; //variable for going through the questions.txt file
const int num_ques=29; //includes number of questions
char choice; //main menu variable
int countr = 0; //score

mainhome:
system("clear"); //source: http://stackoverflow.com/questions/15102976/how-to-clear-screen-from-simple-c-program
//printf("\t\t\tC PROGRAM QUIZ GAME\n");
printf("\n\t\t________________________________________");

printf("\n\t\t\t * WELCOME *");
printf("\n\t\t\t * to *");
printf("\n\t\t\t * AVA'S GAME SHOW *");
printf("\n\t\t ____*_*_*_*_*_*_*_*_*_*_*_*____");
printf("\n\t\t________________________________________");
printf("\n\t\t\t BECOME THE CHAMPION!!! ") ;
printf("\n\t\t________________________________________");
printf("\n\t\t________________________________________");
printf("\n\t\t > Press S to start the game");
printf("\n\t\t > press H for help ");
printf("\n\t\t > press Q to quit ");
printf("\n\t\t________________________________________\n\n");


printf("\n\n\tAnswers must all begin with an uppercase letter\n\n\n");
//MAIN MENU SELECTION OPTIONS
choice=toupper(getchar());
printf("you entered %c\n",choice);

if (toupper(getchar())=='S')
goto home;
else if (choice=='H'){
printf("you typed in H");
help();
getchar();
goto mainhome;
}
else if (choice=='Q'){
printf("you typed in Q");
exit(1);

}


home:
//HAVING QUESTIONS PRINT ONE AT A TIME
for (e=0; e < num_ques; e++) //loop to go through each question in text file
{
//printf("\nQuestion:");
printf("\n***Type in your answer to the following question:\n\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL)
{
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c

if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL)
{
fprintf(stderr,"Error while reading file\n");
return -1;
}



for (i=0; i < 1; i++)
{
// printf("%d\n",i);
//fprintf(stderr,"DIAGNOSTIC -- the answer: %s\n", ans_arr);
//printf("DIAGNOSTIC -- GUESS variable is:%s\n", guess);
fgets(guess, sizeof(guess), stdin);

//fprintf(stderr,"you answered %s\n",guess);

if (strcmp(ans_arr, guess) == 0)
{
printf("Your guess was correct\n\n");
countr++;
}
else if (guess!=ans_arr)
{
printf("Your guess was incorrect.\n");
printf("The answer was: %s\n\n\n\n", ans_arr);
}
else
{
printf("You ran out of questions.");
}
}
}


fclose(questions);
fclose(answers);

//SHOWING THE CONTESTANT THEIR SCORE - HOW MANY QUESTIONS THEY GOT CORRECT
score:
system("clear");
//score=countr;
//printf("* DIAGNOSTIC -- countr is %d\n",countr);
//printf("* DIAGNOSTIC -- score is %d\n",score);
if(countr>0 && countr<=29){
printf("\n\n\t\t************* CONGRATULATIONS **************");
printf("\n\t\t\t You won %d points! \n", countr);
}

else if(countr==30){ //highest score possible
printf("\n\n\n \t\t*********** Nice Job!! ***********");
printf("\n\t\t\t\t You are the champion!!!!!!!!!");
printf("\n\t\t\t You won %d points! \n",countr);
printf("\t\t Thank You!!");
}
else{
printf("\n\n\t******** You did not win any points ********");
printf("\n\t\t Thanks for playing!. \n");
printf("\n\t\t Better luck next time! \n");
}



return 0;


}
30 changes: 30 additions & 0 deletions FinalProject/readme.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
Ava N.
July 15, 2016
Ava's Quiz Game

This is a quiz show game programmed in C during Columbia HSP. My project takes questions from 'questions.txt' and answers from 'answer.txt' to these questions. There is a 'help' center, a 'quit' command, and a command to start the game. All instructions of how to play the game are inside of the game. This is a one player game.


In my proposal, I mentioned including a timer; however, I decided in the end not to add one. I also stated in my introduction that I would have different slots for different categories with different point systems. I later decided that I would not have different categories but a list of questions that players of 'Ava's Quiz Game' would need to answer. Although I did not have time to include graphics, I created a fun looking 'main menu'!

All of the answers to the questions, if you want to beat the game, are in answer.txt .


I got my idea of how to set up Ava's Quiz Show here: http://www.codewithc.com/quiz-game-mini-project-in-c/



Files used in Ava's Quiz Show: [quiz_game.c], [questions.txt], and [answers.txt]. All other files in Final Code folder were used to test the code in the main file.


I hope you enjoy Ava's Quiz Show!



compile statement:
gcc quiz_game.c -o quiz_game
./quiz_game




Binary file addedFinalProject/sam
Binary file not shown.
59 changes: 59 additions & 0 deletions FinalProject/sample_doc.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
//This is for checking the code of the question-answer section in quiz_game code

#include <stdio.h>
#include <string.h>

int main (void){
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[25]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i;
int e;
const int num_ques=5;
for (e=0; e < num_ques; e++){

printf("Type in your answer to the following question:\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL){ //read 1 line from file
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c
if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL){
fprintf(stderr,"Error while reading file\n");
return -1;
}

for (i=0; i < 1; i++){ //Loop for questions asking
//printf("%d\n",i);
//fprintf(stderr,"the answer: %s\n", ans_arr);
//printf("Please guess the word: \n");
fgets(guess, sizeof(guess), stdin);

fprintf(stderr,"you answered %s\n",guess);
if (strcmp(ans_arr, guess) == 0){
printf("Your guess was correct\n\n");
//continue;
}
else if (guess!=ans_arr){
printf("Your guess was incorrect.\n\n\n");
//continue;
}
else {
printf("You ran out of questions");
//break;
}
}
}


fclose(questions);
fclose(answers);
return 0;
}


Binary file addedFinalProject/temp
Binary file not shown.
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions AvaFinalProject.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
Ava N.
July 9, 2016

Final Project Proposal:

For my final project, I would like to create a quiz show, similar to Jeopardy. The objective of the game is to answer as many questions correctly as possible. I will be adding a time limit as well.

The questions would be divided into different categories. For example, under the "computer science" category, the lowest, or '100' slot question might state: 'This device was used to solve math problems before the invention of electricity." The answer, which would not be case sensitive, would be inputed by the contestant/player. Also, I am deciding whether to require the player input to include "what is ..." before the answer. This game will be created for a single-player, but if I have time, I would like to make a 2, 3, or 4 player option as well.

An example of a loop I would use is for the fill-in the answer section. If the correct answer is chosen, then the point goes to the player who asked the question (under a time limit). If that person does not answer correctly or under the time limit, it will go to the next player, and if that player answers correctly, then the original amount of points will get split in half. I will also use functions for the input of the contestant.

I am choosing this project because taking part in a quiz show or game is so much fun, and playing one that I create would be great. I am excited to develop the game design and decide how I will arrange the 'answers' and the 'questions', and where I will put the timer, and arrange different color schemes.

Libraries I will use are the include the ones we have used in class: stdio.h, string.h, math.h, etc. I plan to use the time.h library for the timer. For graphics, I may want to use Cairo, although I have never used that library before.

This is my Final Project Proposal and I am excited to start working on it (once it is approved)!
30 changes: 30 additions & 0 deletions FinalProject/answer.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
Army
Switzerland
Hyena
New York City
Mudd
Winter
700
February
Bonjour
Whale
1492
Abacus
Orange
P
Hydrogen
24
Nile River
Mount Everest
Elvis Presley
Damascus
Sicily
Venezuela
Retriever
1984
Theodore Roosevelt
6
1509
Queue
Ada Lovelace
Yes
1 change: 1 addition & 0 deletions FinalProject/extra.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@

30 changes: 30 additions & 0 deletions FinalProject/questions.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1. What is a group of frogs known as?
2. What country has the highest environmental performance index?
3. Which animal laughs like human being?
4. In which city is manhattan located?
5. In which building is the Columbia HSP for Intro to Programming in C?
6. During what season do animals hybernate?
7. How much wood would a woodchuck chuck if a woodchuck could chuck wood (answer in pounds)?
8. In what month is Valentine's Day?
9. How do you say 'Hello/Good morning' in french?
10. Which underwater creature is bigger: Dolphin or Whale?
11. In what year did Christopher Columbus sail the ocean blue?
12. What device was used to solve math problems before the invention of electricity?
13. What color comes after red in the rainbow?
14. What is the 16th letter in the alphabet?
15. What is the first element in the periodic table (not in scientific notation)?
16. How many students are in the Introduction to Programming in C class?
17. What is the longest river in the world? (include 'River' at the end of answer)
18. What is the highest mountain in the world?
19. Who is known for being the King of Rock 'n Roll?
20. What is the world's oldest city?
21. What is the largest island in the Mediterranean sea?
22. In what country is the highest waterfall in the world?
23. What is the most popoular breed of dog?
24. In which year was the first computer sold with a mouse?
25. Who was the youngest President in the United States?
26. How many legs do butterflies have?
27. In which year did Henry VIII become King of England?
28. What is a linear data structure in which elements are added on one end and removed from the other?
29. Which female mathematician developed the first algorithm for the Analytical Machine?
30. Did you enjoy playing? (Yes/No)
Binary file addedFinalProject/quiz_game
Binary file not shown.
170 changes: 170 additions & 0 deletions FinalProject/quiz_game.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
//Ava N.'s

//REAL VERSION -- Ava's Quiz Show
//Columbia HSP FInal Project
//Intro to Programming in C
//Due: July 15, 2016

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>


void help(){ //gives instructions of the game
system("clear");
printf("\n\n Instructions:");
printf("\n ------------------------------------------------------");
printf("\n ................... Ava's Quiz Show ....................");
printf("\n >> You have to be able to answer 30 questions correctly.");
printf("\n >> All of the questions require fill-in answers.");
printf("\n >> This game is case-sensitive, so all answers have to");
printf("\n have the first letter of each word uppercase.");
printf("\n >> If the question asks for a number, answer with a number.");
printf("\n >> The maximum number of points a you can get is 11.");

printf("\n >> You will not be penalized for incorrect answers.");

printf("\n\n\t**************Good Luck*******************\n\n");
printf("\n\n\t Press 'enter' to continue to the main menu\n");
}



//start of the game show
int main(void){

system("clear");
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[100]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i; //variable for loop that checks contestants answers
int e; //variable for going through the questions.txt file
const int num_ques=29; //includes number of questions
char choice; //main menu variable
int countr = 0; //score

mainhome:
system("clear"); //source: http://stackoverflow.com/questions/15102976/how-to-clear-screen-from-simple-c-program
//printf("\t\t\tC PROGRAM QUIZ GAME\n");
printf("\n\t\t________________________________________");

printf("\n\t\t\t * WELCOME *");
printf("\n\t\t\t * to *");
printf("\n\t\t\t * AVA'S GAME SHOW *");
printf("\n\t\t ____*_*_*_*_*_*_*_*_*_*_*_*____");
printf("\n\t\t________________________________________");
printf("\n\t\t\t BECOME THE CHAMPION!!! ") ;
printf("\n\t\t________________________________________");
printf("\n\t\t________________________________________");
printf("\n\t\t > Press S to start the game");
printf("\n\t\t > press H for help ");
printf("\n\t\t > press Q to quit ");
printf("\n\t\t________________________________________\n\n");


printf("\n\n\tAnswers must all begin with an uppercase letter\n\n\n");
//MAIN MENU SELECTION OPTIONS
choice=toupper(getchar());
printf("you entered %c\n",choice);

if (toupper(getchar())=='S')
goto home;
else if (choice=='H'){
printf("you typed in H");
help();
getchar();
goto mainhome;
}
else if (choice=='Q'){
printf("you typed in Q");
exit(1);

}


home:
//HAVING QUESTIONS PRINT ONE AT A TIME
for (e=0; e < num_ques; e++) //loop to go through each question in text file
{
//printf("\nQuestion:");
printf("\n***Type in your answer to the following question:\n\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL)
{
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c

if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL)
{
fprintf(stderr,"Error while reading file\n");
return -1;
}



for (i=0; i < 1; i++)
{
// printf("%d\n",i);
//fprintf(stderr,"DIAGNOSTIC -- the answer: %s\n", ans_arr);
//printf("DIAGNOSTIC -- GUESS variable is:%s\n", guess);
fgets(guess, sizeof(guess), stdin);

//fprintf(stderr,"you answered %s\n",guess);

if (strcmp(ans_arr, guess) == 0)
{
printf("Your guess was correct\n\n");
countr++;
}
else if (guess!=ans_arr)
{
printf("Your guess was incorrect.\n");
printf("The answer was: %s\n\n\n\n", ans_arr);
}
else
{
printf("You ran out of questions.");
}
}
}


fclose(questions);
fclose(answers);

//SHOWING THE CONTESTANT THEIR SCORE - HOW MANY QUESTIONS THEY GOT CORRECT
score:
system("clear");
//score=countr;
//printf("* DIAGNOSTIC -- countr is %d\n",countr);
//printf("* DIAGNOSTIC -- score is %d\n",score);
if(countr>0 && countr<=29){
printf("\n\n\t\t************* CONGRATULATIONS **************");
printf("\n\t\t\t You won %d points! \n", countr);
}

else if(countr==30){ //highest score possible
printf("\n\n\n \t\t*********** Nice Job!! ***********");
printf("\n\t\t\t\t You are the champion!!!!!!!!!");
printf("\n\t\t\t You won %d points! \n",countr);
printf("\t\t Thank You!!");
}
else{
printf("\n\n\t******** You did not win any points ********");
printf("\n\t\t Thanks for playing!. \n");
printf("\n\t\t Better luck next time! \n");
}



return 0;


}
30 changes: 30 additions & 0 deletions FinalProject/readme.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
Ava N.
July 15, 2016
Ava's Quiz Game

This is a quiz show game programmed in C during Columbia HSP. My project takes questions from 'questions.txt' and answers from 'answer.txt' to these questions. There is a 'help' center, a 'quit' command, and a command to start the game. All instructions of how to play the game are inside of the game. This is a one player game.


In my proposal, I mentioned including a timer; however, I decided in the end not to add one. I also stated in my introduction that I would have different slots for different categories with different point systems. I later decided that I would not have different categories but a list of questions that players of 'Ava's Quiz Game' would need to answer. Although I did not have time to include graphics, I created a fun looking 'main menu'!

All of the answers to the questions, if you want to beat the game, are in answer.txt .


I got my idea of how to set up Ava's Quiz Show here: http://www.codewithc.com/quiz-game-mini-project-in-c/



Files used in Ava's Quiz Show: [quiz_game.c], [questions.txt], and [answers.txt]. All other files in Final Code folder were used to test the code in the main file.


I hope you enjoy Ava's Quiz Show!



compile statement:
gcc quiz_game.c -o quiz_game
./quiz_game




Binary file addedFinalProject/sam
Binary file not shown.
59 changes: 59 additions & 0 deletions FinalProject/sample_doc.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
//This is for checking the code of the question-answer section in quiz_game code

#include <stdio.h>
#include <string.h>

int main (void){
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[25]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i;
int e;
const int num_ques=5;
for (e=0; e < num_ques; e++){

printf("Type in your answer to the following question:\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL){ //read 1 line from file
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c
if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL){
fprintf(stderr,"Error while reading file\n");
return -1;
}

for (i=0; i < 1; i++){ //Loop for questions asking
//printf("%d\n",i);
//fprintf(stderr,"the answer: %s\n", ans_arr);
//printf("Please guess the word: \n");
fgets(guess, sizeof(guess), stdin);

fprintf(stderr,"you answered %s\n",guess);
if (strcmp(ans_arr, guess) == 0){
printf("Your guess was correct\n\n");
//continue;
}
else if (guess!=ans_arr){
printf("Your guess was incorrect.\n\n\n");
//continue;
}
else {
printf("You ran out of questions");
//break;
}
}
}


fclose(questions);
fclose(answers);
return 0;
}


Binary file addedFinalProject/temp
Binary file not shown.
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions AvaFinalProject.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
Ava N.
July 9, 2016

Final Project Proposal:

For my final project, I would like to create a quiz show, similar to Jeopardy. The objective of the game is to answer as many questions correctly as possible. I will be adding a time limit as well.

The questions would be divided into different categories. For example, under the "computer science" category, the lowest, or '100' slot question might state: 'This device was used to solve math problems before the invention of electricity." The answer, which would not be case sensitive, would be inputed by the contestant/player. Also, I am deciding whether to require the player input to include "what is ..." before the answer. This game will be created for a single-player, but if I have time, I would like to make a 2, 3, or 4 player option as well.

An example of a loop I would use is for the fill-in the answer section. If the correct answer is chosen, then the point goes to the player who asked the question (under a time limit). If that person does not answer correctly or under the time limit, it will go to the next player, and if that player answers correctly, then the original amount of points will get split in half. I will also use functions for the input of the contestant.

I am choosing this project because taking part in a quiz show or game is so much fun, and playing one that I create would be great. I am excited to develop the game design and decide how I will arrange the 'answers' and the 'questions', and where I will put the timer, and arrange different color schemes.

Libraries I will use are the include the ones we have used in class: stdio.h, string.h, math.h, etc. I plan to use the time.h library for the timer. For graphics, I may want to use Cairo, although I have never used that library before.

This is my Final Project Proposal and I am excited to start working on it (once it is approved)!
30 changes: 30 additions & 0 deletions FinalProject/answer.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
Army
Switzerland
Hyena
New York City
Mudd
Winter
700
February
Bonjour
Whale
1492
Abacus
Orange
P
Hydrogen
24
Nile River
Mount Everest
Elvis Presley
Damascus
Sicily
Venezuela
Retriever
1984
Theodore Roosevelt
6
1509
Queue
Ada Lovelace
Yes
1 change: 1 addition & 0 deletions FinalProject/extra.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@

30 changes: 30 additions & 0 deletions FinalProject/questions.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1. What is a group of frogs known as?
2. What country has the highest environmental performance index?
3. Which animal laughs like human being?
4. In which city is manhattan located?
5. In which building is the Columbia HSP for Intro to Programming in C?
6. During what season do animals hybernate?
7. How much wood would a woodchuck chuck if a woodchuck could chuck wood (answer in pounds)?
8. In what month is Valentine's Day?
9. How do you say 'Hello/Good morning' in french?
10. Which underwater creature is bigger: Dolphin or Whale?
11. In what year did Christopher Columbus sail the ocean blue?
12. What device was used to solve math problems before the invention of electricity?
13. What color comes after red in the rainbow?
14. What is the 16th letter in the alphabet?
15. What is the first element in the periodic table (not in scientific notation)?
16. How many students are in the Introduction to Programming in C class?
17. What is the longest river in the world? (include 'River' at the end of answer)
18. What is the highest mountain in the world?
19. Who is known for being the King of Rock 'n Roll?
20. What is the world's oldest city?
21. What is the largest island in the Mediterranean sea?
22. In what country is the highest waterfall in the world?
23. What is the most popoular breed of dog?
24. In which year was the first computer sold with a mouse?
25. Who was the youngest President in the United States?
26. How many legs do butterflies have?
27. In which year did Henry VIII become King of England?
28. What is a linear data structure in which elements are added on one end and removed from the other?
29. Which female mathematician developed the first algorithm for the Analytical Machine?
30. Did you enjoy playing? (Yes/No)
Binary file addedFinalProject/quiz_game
Binary file not shown.
170 changes: 170 additions & 0 deletions FinalProject/quiz_game.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
//Ava N.'s

//REAL VERSION -- Ava's Quiz Show
//Columbia HSP FInal Project
//Intro to Programming in C
//Due: July 15, 2016

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>


void help(){ //gives instructions of the game
system("clear");
printf("\n\n Instructions:");
printf("\n ------------------------------------------------------");
printf("\n ................... Ava's Quiz Show ....................");
printf("\n >> You have to be able to answer 30 questions correctly.");
printf("\n >> All of the questions require fill-in answers.");
printf("\n >> This game is case-sensitive, so all answers have to");
printf("\n have the first letter of each word uppercase.");
printf("\n >> If the question asks for a number, answer with a number.");
printf("\n >> The maximum number of points a you can get is 11.");

printf("\n >> You will not be penalized for incorrect answers.");

printf("\n\n\t**************Good Luck*******************\n\n");
printf("\n\n\t Press 'enter' to continue to the main menu\n");
}



//start of the game show
int main(void){

system("clear");
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[100]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i; //variable for loop that checks contestants answers
int e; //variable for going through the questions.txt file
const int num_ques=29; //includes number of questions
char choice; //main menu variable
int countr = 0; //score

mainhome:
system("clear"); //source: http://stackoverflow.com/questions/15102976/how-to-clear-screen-from-simple-c-program
//printf("\t\t\tC PROGRAM QUIZ GAME\n");
printf("\n\t\t________________________________________");

printf("\n\t\t\t * WELCOME *");
printf("\n\t\t\t * to *");
printf("\n\t\t\t * AVA'S GAME SHOW *");
printf("\n\t\t ____*_*_*_*_*_*_*_*_*_*_*_*____");
printf("\n\t\t________________________________________");
printf("\n\t\t\t BECOME THE CHAMPION!!! ") ;
printf("\n\t\t________________________________________");
printf("\n\t\t________________________________________");
printf("\n\t\t > Press S to start the game");
printf("\n\t\t > press H for help ");
printf("\n\t\t > press Q to quit ");
printf("\n\t\t________________________________________\n\n");


printf("\n\n\tAnswers must all begin with an uppercase letter\n\n\n");
//MAIN MENU SELECTION OPTIONS
choice=toupper(getchar());
printf("you entered %c\n",choice);

if (toupper(getchar())=='S')
goto home;
else if (choice=='H'){
printf("you typed in H");
help();
getchar();
goto mainhome;
}
else if (choice=='Q'){
printf("you typed in Q");
exit(1);

}


home:
//HAVING QUESTIONS PRINT ONE AT A TIME
for (e=0; e < num_ques; e++) //loop to go through each question in text file
{
//printf("\nQuestion:");
printf("\n***Type in your answer to the following question:\n\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL)
{
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c

if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL)
{
fprintf(stderr,"Error while reading file\n");
return -1;
}



for (i=0; i < 1; i++)
{
// printf("%d\n",i);
//fprintf(stderr,"DIAGNOSTIC -- the answer: %s\n", ans_arr);
//printf("DIAGNOSTIC -- GUESS variable is:%s\n", guess);
fgets(guess, sizeof(guess), stdin);

//fprintf(stderr,"you answered %s\n",guess);

if (strcmp(ans_arr, guess) == 0)
{
printf("Your guess was correct\n\n");
countr++;
}
else if (guess!=ans_arr)
{
printf("Your guess was incorrect.\n");
printf("The answer was: %s\n\n\n\n", ans_arr);
}
else
{
printf("You ran out of questions.");
}
}
}


fclose(questions);
fclose(answers);

//SHOWING THE CONTESTANT THEIR SCORE - HOW MANY QUESTIONS THEY GOT CORRECT
score:
system("clear");
//score=countr;
//printf("* DIAGNOSTIC -- countr is %d\n",countr);
//printf("* DIAGNOSTIC -- score is %d\n",score);
if(countr>0 && countr<=29){
printf("\n\n\t\t************* CONGRATULATIONS **************");
printf("\n\t\t\t You won %d points! \n", countr);
}

else if(countr==30){ //highest score possible
printf("\n\n\n \t\t*********** Nice Job!! ***********");
printf("\n\t\t\t\t You are the champion!!!!!!!!!");
printf("\n\t\t\t You won %d points! \n",countr);
printf("\t\t Thank You!!");
}
else{
printf("\n\n\t******** You did not win any points ********");
printf("\n\t\t Thanks for playing!. \n");
printf("\n\t\t Better luck next time! \n");
}



return 0;


}
30 changes: 30 additions & 0 deletions FinalProject/readme.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
Ava N.
July 15, 2016
Ava's Quiz Game

This is a quiz show game programmed in C during Columbia HSP. My project takes questions from 'questions.txt' and answers from 'answer.txt' to these questions. There is a 'help' center, a 'quit' command, and a command to start the game. All instructions of how to play the game are inside of the game. This is a one player game.


In my proposal, I mentioned including a timer; however, I decided in the end not to add one. I also stated in my introduction that I would have different slots for different categories with different point systems. I later decided that I would not have different categories but a list of questions that players of 'Ava's Quiz Game' would need to answer. Although I did not have time to include graphics, I created a fun looking 'main menu'!

All of the answers to the questions, if you want to beat the game, are in answer.txt .


I got my idea of how to set up Ava's Quiz Show here: http://www.codewithc.com/quiz-game-mini-project-in-c/



Files used in Ava's Quiz Show: [quiz_game.c], [questions.txt], and [answers.txt]. All other files in Final Code folder were used to test the code in the main file.


I hope you enjoy Ava's Quiz Show!



compile statement:
gcc quiz_game.c -o quiz_game
./quiz_game




Binary file addedFinalProject/sam
Binary file not shown.
59 changes: 59 additions & 0 deletions FinalProject/sample_doc.c
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
//This is for checking the code of the question-answer section in quiz_game code

#include <stdio.h>
#include <string.h>

int main (void){
char filename[] = "questions.txt"; //opens the questions
char answersFile[]= "answer.txt"; //opens the answers
char ques_arr[1000]; //questions array
char ans_arr[100]; //answers array
char guess[25]; //the contestant's guess
FILE *questions = fopen(filename, "r");
FILE *answers = fopen(answersFile, "r");
int i;
int e;
const int num_ques=5;
for (e=0; e < num_ques; e++){

printf("Type in your answer to the following question:\n");

if(fgets(ques_arr, sizeof(ques_arr), questions)!= NULL){ //read 1 line from file
printf("%s\n", ques_arr);
}

//source: http://stackoverflow.com/questions/8328464/compare-user-input-with-text-file-in-c
if (fgets(ans_arr, sizeof(ans_arr), answers) == NULL){
fprintf(stderr,"Error while reading file\n");
return -1;
}

for (i=0; i < 1; i++){ //Loop for questions asking
//printf("%d\n",i);
//fprintf(stderr,"the answer: %s\n", ans_arr);
//printf("Please guess the word: \n");
fgets(guess, sizeof(guess), stdin);

fprintf(stderr,"you answered %s\n",guess);
if (strcmp(ans_arr, guess) == 0){
printf("Your guess was correct\n\n");
//continue;
}
else if (guess!=ans_arr){
printf("Your guess was incorrect.\n\n\n");
//continue;
}
else {
printf("You ran out of questions");
//break;
}
}
}


fclose(questions);
fclose(answers);
return 0;
}


Binary file addedFinalProject/temp
Binary file not shown.
Loading