Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is for C Programming: For the folloiwng code, I get the follwing errors. Please assist with finding out why I am getting these errors.

This is for C Programming:

For the folloiwng code, I get the follwing errors. Please assist with finding out why I am getting these errors. Thank you so much.

ERRORS:

image text in transcribedimage text in transcribed

CODE:

#include

#include

#include

void showHangman(int);

int main(void)

{

char hangmanWord[100], tempWord[100];

char hangmanOutput[100];

int wrongTry = 6 , matchFound = 0;

int counter = 0 , position = 0, winner, length , i;

char alphabetFromUser;

system("cls");

printf(" Enter any word in small case and hit >>ENTER

printf(" \t Enter HERE ==> ");

scanf("%s",hangmanWord);

printf(" Now give the COMPUTER to your friend and see if he/she can CRACK it!!!");

printf(" \tHIT >>ENTER

getchar();

length = strlen(hangmanWord);

system("cls");

printf(" !!!!!!!!Welcome !!!!!! "); /**Brief description of the game**/

printf(" You will get 5 chances to guess the right word");

printf(" So help the Man and get...set...GO..!!");

getchar();

printf(" \tHIT >>ENTER

getchar();

system("cls");

printf(" \t||===== "); /**show the HANGMAN**/

printf(" \t|| | ");

printf(" \t|| ");

printf(" \t|| ");

printf(" \t|| ");

printf(" \t|| ");

printf(" The word has %d alphabets ",length); /**tell the user how many alphabets the word has**/

for( i = 0; i

{

hangmanOutput[i] = '_';

hangmanOutput[length] = '\0';

}

for(i = 0 ; i

{

printf(" ");

printf("%c",hangmanOutput[i]); /**Show the Word With n(length of the original word) number of underscores (_)**/

}

while(wrongTry != 0)

{

matchFound = 0;

printf(" enter any alphabet from a to z and please use small case!!");

printf(" \t Enter HERE ==> ");

fflush(stdin);

scanf("%c",&alphabetFromUser);

if(alphabetFromUser 'z') /**In case player gives input other than 'a' to 'z' the console will ask again**/

{

system("cls");

printf(" \t Wrong input TRY AGAIN ");

matchFound = 2;

}

fflush(stdin);

if (matchFound != 2)

{

for(counter=0;counter

{

if(alphabetFromUser==hangmanWord[counter])

{

matchFound = 1;

}//end of if()

}//end of for()

if(matchFound == 0)

{

printf(" \t :( You have %d tries left ",--wrongTry);

getchar();

showHangman(wrongTry);

getchar();

}//end of if()

else

{

for(counter = 0; counter

{

matchFound = 0;

if(alphabetFromUser == hangmanWord[counter])

{

position = counter ;

matchFound = 1;

}//end of if

if(matchFound == 1)

{

for(i = 0 ; i

{

if( i == position)

{

hangmanOutput[i] = alphabetFromUser; /**Put the alphabet at right position**/

}

else if( hangmanOutput[i] >= 'a' && hangmanOutput[i]

{

continue;

}

else

{

hangmanOutput[i] = '_'; /** Put a blank at not guessed alphabet position **/

}

}

tempWord[position] = alphabetFromUser; /**put the alphabet in another char array to check with the original word**/

tempWord[length] = '\0'; /**put the NULL character at the end of the temp string**/

winner = strcmp(tempWord,hangmanWord); /**upon True comparison it will return 0**/

if(winner == 0)

printf(" \t \t YAHOO!!!!! You are the WINNER !!!!!");

printf(" \t The Word was %s ",hangmanWord);

printf(" \t\tEASY HUH??? ");

getchar();

return 0;

}//end of inner if

}//end of outer if

}//end of for loop

}//end of else

}// end of if(matchFound != 2) condition

printf(" \t");

for(i = 0 ; i

{

printf(" ");

printf("%c",hangmanOutput[i]);

}

getchar();

}//end of while loop

if(wrongTry

{

printf(" \t The Word was %s ",hangmanWord);

printf(" \t The man is dead you IDIOT!!!!!");

printf(" \t Better luck next!!!");

}

getchar();

return 0;

}//end of main();

void showHangman(int choice) /**This function show the hangman after each wrong try**/

{

switch(choice)

{

case 0:

system("cls");

printf(" \t||===== ");

printf(" \t|| | ");

printf(" \t|| %cO/",'\\');

printf(" \t|| | ");

printf(" \t|| / %c",'\\');

printf(" \t|| ");

break;

case 1:

system("cls");

printf(" \t||===== ");

printf(" \t|| | ");

printf(" \t|| %cO/",'\\');

printf(" \t|| | ");

printf(" \t|| %c",'\\');

printf(" \t|| ");

break;

case 2:

system("cls");

printf(" \t||===== ");

printf(" \t|| | ");

printf(" \t|| %cO/",'\\');

printf(" \t|| | ");

printf(" \t|| ");

printf(" \t|| ");

break;

case 3:

system("cls");

printf(" \t||===== ");

printf(" \t|| | ");

printf(" \t|| %cO/",'\\');

printf(" \t|| ");

printf(" \t|| ");

printf(" \t|| ");

break;

case 4:

system("cls");

printf(" \t||===== ");

printf(" \t|| | ");

printf(" \t|| %cO ",'\\');

printf(" \t|| ");

printf(" \t|| ");

printf(" \t|| ");

break;

case 5:

system("cls");

printf(" \t||===== ");

printf(" \t|| | ");

printf(" \t|| O ");

printf(" \t|| ");

printf(" \t|| ");

printf(" \t|| ");

break;

}

return;

}

hangnan1.c:247 : 7: error: expected identifier or (' before if' t guess the whole word in 5 chaces** hangman1.c:259:1: warning: data definition has no type or storage class if(wrongTry 0) /**if the player can no getchar(); warning: type defaults to int, 1n declaration of getchar, [- hangman1.c:259:1: Wimplicit-int] hangman! . c : 261 : 1 : error: expected identifier or (' before return, return hangnan1.c:263:1: expected identifier or (' before )' token error: //end of main(); cop3014@cop3014: $ clear cop3014@cop3014: $ gedit hangnan1.c cop3014@cop3014: $ gcc-o hangman1 hangman1.c hangman! . c : 247 :7 : error: expected dentifier or (' before if' if(wrongTry 0) /**if the player can no t guess the whole word in 5 chaces** hangman1.c:259:1: warning: data definition has no tvpe or storage class

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

50 Tips And Tricks For MongoDB Developers Get The Most Out Of Your Database

Authors: Kristina Chodorow

1st Edition

1449304613, 978-1449304614

More Books

Students also viewed these Databases questions

Question

Why can investments in inventory be costly?

Answered: 1 week ago