Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › C++/C Programming › [Question] Random number below a set number

[Question] Random number below a set number

Posts 1–5 of 5 · Page 1 of 1
That0n3Guy
That0n3Guy
[Question] Random number below a set number
OK, so basically I want to make a guessing game. The variable "CorrectGuess" should be random. I found a lot of articles on random numbers, ranging from printing out 1-10 to just generating any old number. I want the number to be less then AND greater then a certain number. (Like greater then 1 less then 100) Any help on this subject would be extremely appreciated.
#1 · 16y ago
why06
why06
Quote Originally Posted by That0n3Guy View Post
OK, so basically I want to make a guessing game. The variable "CorrectGuess" should be random. I found a lot of articles on random numbers, ranging from printing out 1-10 to just generating any old number. I want the number to be less then AND greater then a certain number. (Like greater then 1 less then 100) Any help on this subject would be extremely appreciated.
I've actually always wanted to do this, because the rand() in Java is different from the rand() in C++. Basically all you need to do is call rand() and then "mod" it '%' by watever values you want the random number between.

So:
Code:
rand() % 10;
Would give you values between 0-9;
Code:
 rand()% 10 +1;
Would give you values between 1-10;

rand - C++ Reference
#2 · 16y ago
radnomguywfq3
radnomguywfq3
If I'm correct, you need to give rand a seed first(a number to apply some mathematical algorithm to, thus generating a random number). To do this you must first call srand, which will set the seed. A good place to find a seed is to get the system up time and use that.


rand
srand
GetTickCount Function (Windows)


Better yet, consider using
http://msdn.microsof*****m/en-us/libr...a8(VS.80).aspx

int iRandom;
rand_s(&iRandom);
#3 · edited 16y ago · 16y ago
That0n3Guy
That0n3Guy
Thank you both for your replies, I'm going to look into it.
#4 · 16y ago
BO
BooYa
C++ Random Numbers - C++
#5 · 16y ago
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

  • [Question]Random Number+Letter GeneratorBy Dreamer in Visual Basic Programming
    4Last post 16y ago
  • [TuT]Generate Random NumberBy Iamazn1 in Visual Basic Programming
    1Last post 16y ago
  • Fill with random numbers between 0-12By ppl2pass in Visual Basic Programming
    13Last post 16y ago
  • [Solved]Random number helpBy poneboy00 in Visual Basic Programming
    5Last post 16y ago
  • Random Number GeneratorBy Iam"iDude" in Visual Basic Programming
    5Last post 18y ago

Tags for this Thread

#number#question#random#set