Question

In: Computer Science

using the C programming language I need a program that includes comments/ screen shots that it...

using the C programming language I need a program that includes comments/ screen shots that it works/ and the code it self

for a hang man game

this game has to be to complie no errors please you can even keep it super basic if u want and no( studio.c) that never works THANK UUUUUU

Solutions

Expert Solution

Please find the pseudo code below:

  1. Initialize a string to store words required for the game.
  2. Use random value generator to get an index to choose random word.
  3. Enter letter
  4. Check if the letter exisit in the word
  5. If the letter does not exisit:
    1. Add new element in the picture
  6. If the letter exisit:
    1. Increment loop and move forward to next element
  7. Continue till maximum times i.e. 8

[PS: Its basic program. Error handling needs to be added.

Also when word is less than 8 and even if you enter the correct letters the while loop continues for complete 8 times.]

 #include <iostream> #include <string> using namespace std; #define MAX_TRY 8 void draw(char *part) {      cout << "\t____________________________________________" << endl << endl;     cout << "\t| " << part[0] << endl;    cout << "\t| " << part[1] << endl;    cout << "\t| " << part[2] << endl;    cout << "\t| " << part[3] << " " << part[4] << endl;      cout << "\t| " << part[5] << endl;    cout << "\t| " << part[6] << " " << part[7] << endl;      cout << "\t|" << endl;      cout << "\t____________________________________________" << endl; } bool checkLetter(string word, string letter) {          if (word.find(letter) != string::npos)          return 1; // Letter found       else            return 0; // Letter not found } int main() {    string country[] = {"America", "Australia", "Canada", "Ireland", "London"};     char part[MAX_TRY] = {};        unsigned char count = 0, error = 0;     string word, letter;    int n = rand() % 6; // To randomly choose from country[]        cout << "Welcome to Hangman" << endl;       word = country[0];      while (count < MAX_TRY) { // Check if it hits maximum tries or if it crosses the word size           cout << " Enter your input:";             cin >> letter;            bool isFound = checkLetter(word, letter); // Check if the letter exist in the word or not               if (!isFound) {                         switch (error) { //Enter new element in Hangman Picture                         case 0:                                 part[0] = '|'; break;                   case 1:                                 part[1] = '|'; break;                   case 2:                                 part[2] = 'O'; break;                   case 3:                                 part[3] = '/'; break;                   case 4:                                 part[4] = '\\'; break;                  case 5:                                 part[5] = '|'; break;                   case 6:                                 part[6] = '/'; break;                   case 7:                                 part[7] = '\\'; break;                  }                       error++;                        draw(&part[0]);                                     }               count++;        }       cout << endl;     cout << "========================================" << endl;         if ((error < MAX_TRY) && (error < word.size())) {                 cout << "\tYou Won !!!!!!!!!!" << endl;     }       else {          cout << "\tYou Lose !!!!!!!!!!" << endl;    }       cout << "\tAnswer: " << word << endl;         cout << "========================================" << endl << endl;   return 0; }


Related Solutions

I need to complete this C++ program. The instructions are in the comments inside the code...
I need to complete this C++ program. The instructions are in the comments inside the code below: ------------------------------------------------------------------------- Original string is: this is a secret! Encypted string is: uijt!jt!b!tfdsfu" Decrypted string is: this is a secret! //Encoding program //Pre-_____? //other necessary stuff here int main() { //create a string to encrypt using a char array cout<< "Original string is: "<<string<<endl; encrypt(string); cout<< "Encrypted string is: "<<string<<endl; decrypt(string); cout<<"Decrypted string is: "<<string<<endl; return 0; } void encrypt(char e[]) { //Write implementation...
i need C++ program with possible comments what is going on,(a) Write a program that reads...
i need C++ program with possible comments what is going on,(a) Write a program that reads a char as input, and determines if it is a lowercase letter, uppercase letter, a digit or something else (call the last one a special character).
C Programming language problem I need to write a program which uses several threads (like 8...
C Programming language problem I need to write a program which uses several threads (like 8 threads for example) to sum up a number. The following program is using 1 thread but I need several threads to compile it. There was a hint saying that using multiple separate for loop and combining them will make a multi-threaded program. #include <stdio.h> #include <stdlib.h> #include <pthread.h> int sum; // this data is shared by the threads void *runner(void *param); // threads call...
You are using ONLY Programming Language C for this: In this program you will calculate the...
You are using ONLY Programming Language C for this: In this program you will calculate the average of x students’ grades (grades will be stored in an array). Here are some guidelines to follow to help you out: 1. In your program, be sure to ask the user for the number of students that are in the class. The number will help in declaring your array. 2. Use the function to scan the grades of the array. To say another...
Programming Language Required: C Write a multithreaded program in C (not c++) using the pthread library...
Programming Language Required: C Write a multithreaded program in C (not c++) using the pthread library and dynamic memory(malloc) that multiplies two matrices together. The numbers in the matrices must be read in from a text file. The program should also check if the two matrices are capable of being multiplied together. The amount of threads used has to be dynamic. The user should be able to choose how many threads they wish to use using the command line. Finally,...
Note: I need a code and other requirement Note: programming language is c++ If you need...
Note: I need a code and other requirement Note: programming language is c++ If you need more information, please clarify what information you want. consider solving the equation sin(x) - e^(-x) = 0 write a computer program to solve the given equation using: 1- bisection method 2- fixed-point method 3- newton's intervals: {0,1},{1,2},{2,3},{3,4},{4,5},{5,6},{6,7},{7,8},{8,9},{9,10} choose accuracy E = 10^(-5) Make sure you document your program Requirement : 1- Mathematical justification 2- algorithem description 3- code (program) with documentation 4-output: roots ,...
I am building a game in C programming language where I need to add objects of...
I am building a game in C programming language where I need to add objects of various length into a game board. The game board is 8X8 and we must account for the boundaries for the board and not go over them with our objects. The boards upper left corner is at 0x0 and we must return 1 if it fits and -1 if it does not fit. I have the following 2 functions to start with: ```int add_object_vert(int r,...
SHOW SCREEN SHOTS OF THE INPUT AND OUTPUT AS WELL AS THE RESULTS PROGRAMMING IN PERL...
SHOW SCREEN SHOTS OF THE INPUT AND OUTPUT AS WELL AS THE RESULTS PROGRAMMING IN PERL Task 2: Variables 2.1 Scalar Variables A scalar is a single unit of data. That data might be an integer number, floating point, a character, a string, a paragraph, or an entire web page. Simply saying it could be anything, but only a single thing. #!/usr/bin/perl $age = 35; # An integer assignment $name = "Gary Mann"; # A string $salary = 5445.50; #...
Solve problems using Minitab. Show evidence that they used the program by putting screen shots of...
Solve problems using Minitab. Show evidence that they used the program by putting screen shots of the results. Will give good rating. Exercises: 1. Among the 120 applicants for a job, only 80 are qualified. If 5 of these applicants are selected at random for an interview, answer the following: to. Identify the random process b. Define a variable c. Associate the random variable with a distribution and its parameters Solve the following questions using Minitab: d. Find the probability...
Solve problems using Minitab. Show evidence that they used the program by putting screen shots of...
Solve problems using Minitab. Show evidence that they used the program by putting screen shots of the results. Will give good rating 2. On a certain cruise, there are, on average, 3 traffic accidents each month. Answer the following: to. Identify the random process b. Define a variable c. Associate the random variable with a distribution and its parameters Solve the following questions using Minitab: d. Find the probability that in a period of 2 months exactly 4 accidents will...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT