All pastes #46866 Raw Edit

Something

public text v1 · immutable
#46866 ·published 2006-03-24 20:00 UTC
rendered paste body
/***************************************************\
*	Name:		Program2							*
*	Purpose:	To play a game of hangman			*
*	Date:		3-15-06								*
*	Author:		Katharina van Santen				*
\***************************************************/

#include <stdio.h>
void main (void)

{
	char g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11;
	char guess=' ';
	char temp= ' ';
	int chances = 6;
	int won=0;

	
	g1= '_';
	g2= '_';
	g3= '_';
	g4= '_';
	g5= '_';
	g6= '_';
	g7= '_';
	g8= '_';
	g9= '_';
	g10='_';
	g11='_';



// start of loop
while (chances > 0 || won == 1)

{
	printf("\n%c %c %c %c %c %c %c %c %c %c %c\n\n",g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11);
	printf("Please enter a letter\t");
	guess = getchar();
	temp = getchar();

	if (guess=='i') 
	{
		g1= 'i';
		g9= 'i';
	}
	else if (guess=='n')
	{
		g2= 'n';
		g7= 'n';
	}
	else if (guess=='e')
	{
		g3= 'e';
		g6= 'e';
		g11='e';
	}
	else if (guess=='x')
	{
		g4= 'x';
	}
	else if (guess=='p')
	{
		g5= 'p';
	}
	else if (guess=='s')
	{
		g8= 's';
	}
	else if (guess=='v')
	{
		g10='v';
	}

	else
	{
		printf("This letter '%c' is not in this word.\n\n", guess);
	}
	chances--;

	if (chances==5)
	{
		printf("\tO\n\n");
	}

	if (chances==4)
	{
		printf("\tO\n\t|");
	}

	if (chances==3)
	{
		printf("\tO\n       \\|\n");
	}

	if (chances==2)
	{
		printf("\tO\n       \\|/\n");
	}

	if (chances==1)
	{
		printf("\tO\n       \\|/\n       /");
	}

	if (g1!='_'&&g2!='_'&&g3!='_'&&g4!='_'&&g5!='_'&&g6!='_'&&g7!='_'&&g8!='_'&&g9!='_'&&g10!='_'&&g11!='_')
	{
		won=1;
		printf("Congratulations you win!\n");
	}
	else
	{
		printf("\nYou have %d chances remaining\n\n", chances);
	}
}	

	if (chances==0)
	{
	printf("\tO\n       \\|/\n       / \\");
	printf("\nYou are out of chances, you loose!\nThe word was inexpensive\n\n");
	}

	else
	{
	printf("\nYou Win!\n\n");
	}

}