Untitled
unknown
scheme
4 years ago
1.5 kB
6
Indexable
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
//defining functions
int nComputerGuess(int, int);
int nUserGuess(int, int);
int main () {
int a;
printf("Welcome to Guess The Number Game. Play and Win. \n");
srand(time(null));
a=(rand()%100)+1;
= nComputerGuess(nMin, nMax);
return 0;
}
//function declaration
int nComputerGuess(int nMin, int nMax){
int nCompGuess;
int nUserInput;
printf("Please enter the range: \n"); // lele mes u muno se nuk munesh mi kuptu okej po po mer
scanf("%d%d", nMin, nMax);
if (nUserInput < nMin || nUserInput > nMax){
printf("Please define a normal range: \n");
}
printf("Please enter your secret number: \n");
scanf("%d", &nUserInput);
while( nCompGuess != nUserInput ){
if (nCompGuess < nUserInput){
printf("The secret number is bigger than %d\n ", nUserInput);
} else {
printf("The secret number is smaller than %d\n", nUserInput);
}
}
}
int nUserGuess(int nMin, int nMax){
int nUserrGuess;
int nCompSecretNum;
printf("Please enter the range: \n");
scanf("%d%d", nMin, nMax);
if (nUserrGuess < nMin || nUserrGuess > nMax){
printf("Please define a normal range: \n");
}
printf("Please enter your guess for computer's secret number: \n");
scanf("%d", &nUserrGuess);
while( nUserrGuess != nCompSecretNum){
if ( nUserrGuess < nCompSecretNum ){
printf("The secret number is bigger than %d\n", nUserrGuess);
} else{
printf("The secret number is smaller than %d\n", nUserrGuess);
}
}
}Editor is loading...