# Thread: Projects-guessing game

1. ## Projects-guessing game

hi, im new in programming. help me pls. so, this is the problem..
Write a C program that simulates a guessing game. Each turn you choose among 9 possible guesses. As many as five guesses may be made a turn. For each turn the program will generate a random number between 1 and 36. Each correct guess will be rewarded with points based on how many of your current points risked. A game board divides the numbers into rows and columns. The board provides the basis for your guesses. You can guess whether the random is even or odd. In this case, you get 1 point for each point risked when you guess correctly. You can guess whether the number is low (1-12), medium (13-24), or high (25-36). In this case, you will get 2 points for each point risked. You can also guess left, center or right. In this case you get 2 points for each point risked when your guess is correct. Finally, you can guess a specific number between 0 adn 36. In this case you get 36 points for each point risked when your guess is correct. To make the game more interesting each round allows up to five guesses.
here is my example code.

#include<stdio.h>
#include<conio.h>
#include <time.h>

main()
{
srand(time(NULL));
int gu,guess,wins,number = rand() % 36,r,p,t,b =1+(2*rand ()) %10;
char option, go;

do {

printf("========================================== =============\n");
printf("Guesses Choice:\n");
printf("O-Odd E-Even F-Left C-Center R-Right N-Number\n");
printf("========================================== =============\n");

printf("Enter your choice: ");
scanf("%c", &option);

switch (option) {

case 'O':
case 'o':

printf("Odd number from 1-35\n");

printf("\nenter number: ");
scanf("%d",&guess);
printf("Point at risk? ");
scanf("%d",&r);

if(guess<b || guess>b){
p=r;
printf("You lost %d points",p);
}

if(guess==b)
{
t=r+r;
printf("plus points:%d ",t);}

break;

case 'E':
case 'e':
printf("Even number\n");
break;
case 'L':
case 'l':
printf("Low\n");
break;
case 'M':
case 'm':
printf("Medium\n");
break;
case 'H':
case 'h':
printf("High\n");
break;
case 'F':
case 'f':
printf("Left\n");
break;
case 'C':
case 'c':
printf("Center\n");
break;
case 'R':
case 'r':
printf("Right\n");
break;

case 'N':
case 'n':
printf("\n\nNumber\n");

printf("\nenter number: ");
scanf("%d",&guess);
printf("Point at risk? ");
scanf("%d",&r);

if(guess<number || guess>number){
p=r;
printf("You lost %d points",p);
}

if(guess==number)
{
t=r+r;
printf("plus points:%d ",t);}
break;

default:
printf("Try again!\n");
}

printf("\nContinue (Y/N)? ");
scanf("%c", &go);

} while (go == 'Y' || go == 'y');

getch();

}

2. Welcome to the forum, AA!

You need to ALWAYS put C code between code tags (click on the # icon in the advanced editor - top bar). Paste your code between the tags, or paste your code first and then highlight it and click on the # icon.

I like the second way, unless my glasses are VERY clean.

Otherwise, the forum saves space, and reformats your code as html text and basically makes it VERY hard to study it. (Read: it will pretty much be ignored).

Now, specifically, what is the problem with your code? The more specific you are, the more helpful our answers will probably be.

Popular pages Recent additions