Projects-guessing game

This is a discussion on Projects-guessing game within the C Programming forums, part of the General Programming Boards category; hi, im new in programming. help me pls. so, this is the problem.. Write a C program that simulates a ...

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    1

    Post 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();

    }
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    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 subscribe to a feed

Similar Threads

  1. Guessing Game
    By ryansanford in forum C Programming
    Replies: 2
    Last Post: 10-01-2012, 03:06 AM
  2. Guessing game: how to quit the game?
    By hzr in forum C Programming
    Replies: 5
    Last Post: 12-18-2008, 09:53 AM
  3. guessing game
    By Inferno in forum C++ Programming
    Replies: 2
    Last Post: 09-22-2004, 05:37 PM
  4. A guessing game
    By Lyanette in forum C++ Programming
    Replies: 5
    Last Post: 04-03-2003, 09:02 AM
  5. guessing game
    By wayko in forum C++ Programming
    Replies: 11
    Last Post: 09-19-2001, 06:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21