Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*************************filename here.c****************************
- Student Name: ------- Student Number: -------------
- Date: ------------- Course Name: ------------------
- I have exclusive control over this submission via my password.
- By including this statement in this header comment, I certify that:
- 1) I have read and understood the University policy on academic integrity;
- 2) I have completed the Computing with Integrity Tutorial on Moodle; and
- 3) I have achieved at least 80% in the Computing with Integrity Self Test.
- I assert that this work is my own. I have appropriately acknowledged any and all material
- (data, images, ideas or words) that I have used, whether directly quoted or paraphrased.
- Furthermore, I certify that this assignment was prepared by me specifically for this course.
- ****************************************************************************/
- #include <stdio.h>
- #include <stdbool.h>
- #include <stdlib.h>
- #include <time.h>
- int main(void)
- {
- int randNum;
- int guess;
- int choice;
- int input;
- int score = 0;
- bool value;
- printf("Thank you for playing the High and Low game.\n\n");
- do
- {
- srand (time(NULL));
- randNum = (rand()%(14-2))+2;
- if (randNum >= 2 && randNum <= 10)
- {
- printf("The current card is a %d.\n\n", randNum);
- }
- else
- {
- switch(randNum)
- {
- case 11:
- printf("The current card is a Jack.\n\n");
- break;
- case 12:
- printf("The current card is a Queen.\n\n");
- break;
- case 13:
- printf("The current card is a King.\n\n");
- break;
- case 14:
- printf("The current card is an Ace.\n\n");
- break;
- }
- };
- do
- {
- value = true;
- printf("Will the next card be higher(1) or lower(2)? (press 0 to quit)?\n\n");
- scanf("%d", &choice);
- switch(choice)
- {
- case 0:
- input = 0;
- break;
- case 1:
- input = 1;
- break;
- case 2:
- input = 2;
- break;
- default:
- printf("Please enter the correct input!\n");
- value = false;
- };
- }
- while(!value);
- if (input = 1)
- {
- /* The guess should be higher here but how do I do that?
- like (input>randNum) or (randNum>Num)?
- */
- };
- if (input = 2)
- {
- /* Same problem */
- };
- }
- while(input != 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment