Create the necessary functions to make the guessing game work. C Language not C++
#include <stdio.h>
#include <time.h>
#define MAX_TRIES 10
int getRandomNumber();
char playGame();
char playAgain();
int main(){
start_game:
int num = getRandomNum();
char play_again = playGame();
if (play_again == 'Y' || play_again == 'y'){
goto start_game;
}
printf("Bye");
return 0;
}

code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define MAX_TRIES 10
#define MAX 100
#define MIN 1
int getRandomNumber();
char playGame(int num);
char playAgain();
int main(){
int num;
char play_again;
start_game:
num = getRandomNumber();
//pass the value to check
play_again = playGame(num);
if (play_again == 'Y' || play_again == 'y'){
goto start_game;
}
printf("Bye");
return 0;
}
int getRandomNumber(){
//make it random
srand(time(0));
//generate random number between max and min values
return (rand() % (MAX - MIN + 1)) + MIN;
}
char playGame(int num){
int entered;
int tries = MAX_TRIES;
//try untill tries left
while(tries){
printf("\nEnter your Number : ");
scanf("%d",&entered);
if(num == entered){
return playAgain();
}else{
tries--;
if(!tries)
break;
printf("\nYou have %d tries left",tries);
}
}
return playAgain();
}
char playAgain(){
char ch;
printf("\nWanna play again (y/n): ");
scanf(" %c",&ch);
return ch;
}
Create the necessary functions to make the guessing game work. C Language not C++ #include <stdio.h>...
#include<stdio.h>
#include<stdlib.h>
#include <time.h>
int main()
{
/* first you have to let the computer generate a random number.
Then it has to declare how many tries the user has for the game
loop.
we then need the player to enter their guess. After every guess we
have to give an output of how many numbers they have in the right
location
and how many they have the right number. The player will keep
guessing until their 10 tries are...
Translate the following C program to Pep/9 assembly language. #include <stdio.h> int main() { int number; scanf("%d", &number); if (number % 2 == 0) { printf("Even\n"); } else { printf("Odd\n"); } return 0; }
PLease explain output of these two programs: 1. #include <stdio.h> typedef struct { char *name; int x, y; int h, w; } box; typedef struct { unsigned int baud : 5; unsigned int div2 : 1; unsigned int use_external_clock : 1; } flags; int main(int argc, char** argv){ printf("The size of box is %d bytes\n", sizeof(box)); printf("The size of flags is %d bytes\n", sizeof(flags)); return 0; } 2. #include <stdio.h> #include <string.h> /* define simple structure */ struct { unsigned...
Can anyone help me to make this program work in C language, this is a blackjack game #include #include #include void deal(int, int&) void deal(int, int&, int&) int getbet(int); int main() { int totdealer, totplayer; int money, bet, aces; char yesno = 'Y'; _Bool again; srand(time(0)); printf("How much money do you have? "); scanf("%d" , money); while (money>0 && toupper(yesno) == 'Y') { bet = getbet(money); totdealer...
can someone help me with changing this to c++ language #include <stdlib.h> #include <stdio.h> #include <pthread.h> #include <string.h> #include <dirent.h> #include <sys/wait.h> #include <time.h> #include <sys/stat.h> #include <unistd.h> char *pathLog; char *pathRep; struct stat attr; int fileNum, curNum; char *create_logPath(char *directory); void *funcChecker(void *pathSub); void *funcprintTimeAndChanges(void *pathSub); void main(int argc, char *argv[]) { if(argc < 3) { printf("%s must be executed with exactly two additional arguments (pathRep, pathSub)!\n", argv[0]); printf("Typed count is %d\n", argc); printf("Aborted...
Translate the following C program to Pep/9 assembly language. #include <stdio.h> const int limit = 5; int main() { int number; scanf("%d",&number); while (number < limit){ number++; printf("%d",number); } return 0; }
can u please solve it in c++ format,,,, general format which is
#include<stdio.h> .......printf and scanf format
dont worry about the answers i have down
Q3, What is the output of the program shown below and explain why. #include #include <stdio.h> <string.h> int main(void) ( char str[ 39764 int N strlen(str) int nunj for (int i-0; i t Nǐ.de+ printf(") num (str[] 'e); I/ digits range in the ASCII code is 48-57 if (nue > e) f 9 printf( Xdin,...
Plz use c language
"Simon Says" is a memory game where "Simon" Outputs a sequence of 10 characters (R. G. B. Y) and the user must repeat the sequence Create a for loop that compares the two strings starting from index 0 For each match add one point to user Score Upon a mismatch, exit the loop using a break statement Ex The following patterns yield a user Score of 4: simon Pattern: R, R, G, B, R, Y, Y,...
Make a FLOWCHART for the following JAVA Prime Number Guessing Game. import java.util.Random; import java.util.Scanner; public class Project2 { //Creating an random class object static Random r = new Random(); public static void main(String[] args) { char compAns,userAns,ans; int cntUser=0,cntComp=0; /* * Creating an Scanner class object which is used to get the inputs * entered by the user */ Scanner sc = new Scanner(System.in); System.out.println("*************************************"); System.out.println("Prime Number Guessing Game"); System.out.println("Y = Yes , N = No...
I need the programming to be in language C. I am using a program called Zybook Prompt: Write a statement that outputs variable numObjects. End with a newline. Given: #include <stdio.h> int main(void) { int numObjects; scanf("%d", &numObjects); return 0; } What I did so far. I am not sure if its right tho? #include <stdio.h> int main(void) { int numObjects; scanf("%d", &numObjects); printf(" num Objects is "); printf("%d\n", userAge); return 0; }