srand(time(0));
min+(rand()%max);
int my_number=rand();
srand((unsigned)time(0));
int random_integer;
random_integer = (rand()%10)+1;
cout << random_integer << endl;
int getRandomNumber(int min, int max) {
srand((unsigned) time(NULL));
return min + (rand() % (max - min + 1));
}
int getRandomNumber(int min, int max) {
srand((unsigned) time(NULL));
return min + (rand() % (max - min + 1));
}
int getRandomNumber(int min, int max) {
srand((unsigned) time(NULL));
return min + (rand() % (max - min + 1));
}
#include <cstdlib>
#include <iostream>
#include<cmath>
#include<ctime>
using namespace std;
void gameloop(int,int);
int main(int argc, char *argv[])
{
int min;
int max;
cout<<"Welcome to Guess my number!\n";
cout<<"Choose a max number range:";
cin>>max;
cout<<"Thanks now enter the minimim number(greater than zero):";
cin>>min;
gameloop(min,max);
system("PAUSE");
return EXIT_SUCCESS;
}
void gameloop(int min,int max)
{
int a; //this num does nothing
int try_num=0;
srand(time(0));
int my_number;
min + (rand() % (max - min + 1))= my_number;// EPIC HERE IS THE PROBLEM, i need to set mynumber between max and min.
int points;
int input;
cout<<"If you decide to chicken out then hit (0)";
cout<<"Lets get started
, try and guess my number, the more tries it takes you the more points you loose,if you guess it on the first 3 tries and under you get a +3 bonus, if you get it on the first try then you get a +5 bonus, good luck";
cout<<"\nGold=10 points\nSilver=7 points\n bronze=3\n";
while(input!=0)
{
cout<<"Guess my number now:";
cin>>input;
if(input!=my_number){
try_num+=1;
cout<<"Try again:\n\n";
cout<<my_number;//this is only for testing if random #'s are functioning correctly
cout<<endl;
}
if(input==my_number && try_num==1)
points+=5;
else if(input==my_number && try_num>1 && try_num<=3)
points+=3;
if(input==my_number)
{
cout<<"You win this round!"<<"you have "<<points<<"points";
if(try_num==5)
{
cout<<"\n\nYOU SCORED GOLD";
}
else if(try_num==3){
cout<<"\n\nyou scored silver;";
}
}
}
}
#include <cstdlib>
#include <iostream>
#include<cmath>
#include<ctime>
using namespace std;
int randnum(int min,int max)
{
return min + (rand() % (max - min + 1));
}
void gameloop(int,int);
int main(int argc, char *argv[])
{
int min;
int max;
cout<<"Welcome to Guess my number!\n";
cout<<"Choose a max number range:";
cin>>max;
cout<<"Thanks now enter the minimim number(greater than zero):";
cin>>min;
gameloop(min,max);
system("PAUSE");
return EXIT_SUCCESS;
}
void gameloop(int min,int max)
{
int a; //this num does nothing
int try_num=0;
srand(time(NULL));
// EPIC HERE IS THE PROBLEM, i need to set mynumber between max and min.
int points;
int input;
cout<<"If you decide to chicken out then hit (0)";
cout<<"\nGold=5 points\nSilver=3\n";
while(input!=0)
{
cout<<"Guess my number now:";
cin>>input;
if(input!=randnum(min,max)){
try_num+=1;
cout<<"Try again:\n\n";
cout<<randnum(min,max);//this is only for testing if random #'s are functioning correctly
cout<<endl;
}
if(input==randnum(min,max) && try_num==1)
points+=5;
else if(input==randnum(min,max) && try_num>1 && try_num<=3)
points+=3;
if(input==randnum(min,max))
{
cout<<"You win this round!"<<"you have "<<points<<"points";
if(try_num==5)
{
cout<<"\n\nYOU SCORED GOLD";
break;
}
else if(try_num==3){
cout<<"\n\nyou scored silver;";
break;
}
}
}
}
Copyright © 2026, NextGenUpdate.
All Rights Reserved.