i'm having trouble creating a craps game for school, i'm a light weight c user and any help would be amazing!!!

One of the rules on this site is: Do not post homework problems expecting a quick answer without showing any effort yourself.

What do you have so far?

i have everything created but the loop. i am cannot creat a loop to cycle through play once 1 is entered or go to rules once 2 is entered and return to main menu...I have worked hard (all nighter) and am at work now still working on it. i've spent about 10 hours on it and am stuck

Edited 6 Years Ago by mr.confused!: n/a

I have worked hard (all nighter) and am at work now still working on it. i've spent about 10 hours on it and am stuck

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>

#define quit -99
#define menu 0
#define play 1
#define rules 2

int main (void)
{
	
	int x = 0;
	int d1 = 0;
	int d2 = 0;
	int d3 = 0;

	printf("main menu - make a selection\n");
	printf("********************************************************************************");
	printf("\n** 0 - main menu **\n** 1 - play **\n** 2 - rules ** \n** 3 - quit ** \n\n");
	printf("please select choice %d or %d to continue or quit\n", menu, quit);
	printf("********************************************************************************\n\n");
	
	
	d1 = rand () % 6+1;
	d2 = rand () % 6+1;

	scanf("%d", &x);

while ( x != -99 && x <=3 )
	{
	for ( x != -99 && x == 0 )
		{
			if ( x = 0 ) 
				printf("main menu - make a selection\n");
				printf("********************************************************************************");
				printf("\n** 0 - main menu **\n** 1 - play **\n** 2 - rules ** \n** 3 - quit ** \n\n");
				printf("please select choice %d - %d to continue or quit\n", menu, quit);
				printf("********************************************************************************\n\n");
					scanf("%d", &x);
		}
				
	
		for ( x != -99 && x == 1 )
		{
				d3 = d1 + d2;
			printf("you rolled a %d - %d and got a total of %d\n", d1, d2, d3);
			printf("to play again press %d or to quit press %d", play, quit);
			scanf ("%d", x);
		}
		
		for ( x != -99 && x == 2)
		{
			printf("A player must roll 2 6-sided dice and the sum will be totaled.\n");
			printf("If the sum of the dice (on the first roll) is 7 or 11, player wins.\n");
			printf("If a total of 2, 3 or 12 is rolled, you lose.\n");
			printf("If the total is NOT listed above, you roll again to try to make point (a total of 7 or 12).\n");
			printf("If a 7 is rolled while trying to make point, you lose\n");
		}
	}

	return (0);
}

Edited 6 Years Ago by WaltP: Added CODE Tags

Answer 1: The rules section needs "x = 0;" after the "you lose" line.
Answer 2: The "play" section should add "to return to main menu type %d", ... menu
Other comments:
The "for" statements are wrong, the logic inside looks like they should be if's.
All occurrences of x == -99, 0, 1, 2 should be replaced by the constants, e.g.
if (x != quit)
In the statements like (x != quit && x == menu), the (x != quit) is redundant, it is implied by (x == menu)
Single-letter variable names are a bad idea, use longer, self-explanatory names, such as "menu_selection" instead of "x".
The main menu does not need option 0: main menu, which goes back to itself.
The main menu is duplicated; delete the first copy and the code works the same.

Edited 6 Years Ago by UncleLeroy: change while to if. comment on duplicate menu

Comments
you have really helped me out when i was vague on what to do
This article has been dead for over six months. Start a new discussion instead.