Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #pragma warning(suppress : 4996)
- int getguess(int a);
- int magicnumber = 299;
- int main(void)
- {
- char dummyvar;
- int n;
- int g;
- printf("Hi! Try and guess what number I'm thinking of! [Y/N]");
- scanf("%c", &dummyvar);
- printf("Hah! Obviously you do want to guess what number I'm thinking of! Why else would you open this application anyway... Let's start. ");
- for (n=1; n<11; n=n+1)
- {
- g = getguess(n);
- if (g == magicnumber)
- {
- printf("RIGHT! You got it in %d tries! That's really the number I was thinking of! Great job! ", n);
- }
- if (g > magicnumber)
- {
- printf("Hmm... Your guess is higher than the number I'm thinking of... Do try again ");
- }
- if (g < magicnumber)
- {
- printf("Hmm... Your guess is lower than the number I'm thinking of... Do try again ");
- }
- if (n == 10)
- {
- printf("Stop! It is clear to me that you will never be able to guess the number I was thinking of! So I will declare it to you myself, it was %d... Now, Farewell!", magicnumber);
- }
- }
- return 0;
- }
- int getguess(int a)
- {
- int guess;
- printf("Soo, Guess #%d, What do you think the number is?", a);
- scanf("%d", &guess);
- return guess;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement