I know there are a lot of topcs.
I was searching for what i needed.But as i sow there wasn't anything that i can specifically use.
I need a short code that generates 10 random numbers.
Anyone help?
Jackk123
Recommended Answers
Jump to PostThat's nothing a quick google can't help you with. But since you asked here it is :
#include <iostream> #include <ctime> using namespace std; int main(){ srand(time(0)); for(int i = 0; i != 10; ++i){ cout << rand() << endl; } }
Jump to Postdo you need just the function to generate the random numbers or would you like to
know how a rand() like function is working?
Jump to PostYou could use something like this;
#include <iostream> #include <ctime> #include <cstdlib> using namespace std; int main() { //As I remember srand() gave us a begining value to count. srand(time(0)); //expression after rand() funct. represents numbers are between 20 and 10. int i = rand() % 20 …
All 10 Replies
mrnutty
761
Senior Poster
NicAx64
76
Posting Pro
Jackk123
astala27
0
Newbie Poster
Jackk123
NicAx64
76
Posting Pro
Nathaniel10
34
Junior Poster
Jackk123
Jackk123
mrnutty
761
Senior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.