Guess number Game

Source: Internet
Author: User

Thought: The computer generates a random value and guesses if the number is correct.

#include <stdio.h> #include <stdlib.h> #include <time.h>int main () {int start = 1;while (start) {printf ( "Please select: \ n");p rintf ("****1. Play Game ******\n");p rintf ("****0. Exit game ****\n"); scanf_s ("%d", &start); switch (start) {printf ("The game Begins ****\n"), case 1:{int ret = 0;srand ((unsigned) time (NULL)), ret = rand ()% 100;//produces a number from 0 to 100 while (1) {int input = 0; printf ("You guessed: \ n"); scanf_s ("%d", &input), if (Input > Ret) {printf ("Guess big \ n");} else if (Input < ret) {printf ("Guess small \ n");} else{printf ("Congratulations, guess right!\n"); printf ("%d\n", ret);} Break;case 0:break;}} System ("pause"); return 0;}



This article is from the "Years Quiet good" blog, please make sure to keep this source http://01160529.blog.51cto.com/11479142/1794900

Guess number Game

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.