ctime is included to use Time.
And cstdlib (C Standard Library) is used for rand & srand.
Note: Without changing any thing, I executed my program twice, and it gave me different Output, So we get completely Random Numbers in this way.
Time is changing.
srand(time(0)), seed is changing so outcome is changing (variety of random Numbers are being generated
still have confusion...plz help..
ReplyDeleteHave you done what is written on the note?
ReplyDeleteYou haven't read the post below this post, there won't be any problem then.
ReplyDeleteFeel free to ask, but deep thinking to know what is happening will solve your problem.
noi didnt have any concept abt random numbers cuz i bunked that class.....
ReplyDeleteHa ha ha,
ReplyDeleteNo problem:
You can't use rand without srand. Srand is a "seed value". As you sow so shall you reap. A group of random numbers are generated with each particular value of srand. Whenever we use a specific value in srand, a specific group of numbers will be generated, and that specific group of values (so called random) can be obtained whenever we use that number in srand which we used previously.
There is no chance of confusion now.
ReplyDeleteYou look frightened from Random Numbers
#include
ReplyDelete#include
#include
using namespace std;
void main()
{
int a[5][5];
for (int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{a[5][5]=rand();}
cout<< a[5][5]<<endl;
}
}
this program is compiled without using srand...nd i still didint got it....look is we use srand(5); in start and then cout rand using for loop then what srand really do in it...it gives a limit for number or what??
ReplyDeleteThis is the point, how the numbers generated by this program are random numbers, when they are same whenever we run our program?
ReplyDeleteThis is the function of srand to produce different numbers when different numbers are in its parameter.
I take my words back about that we can't use rand without srand.
ReplyDeleteI appreciate your counter example.
And we are not using srand(5) here.
ReplyDeleteno no am not taking abt this progrm that srand(5); means what...
ReplyDeleteam asking generally that what it really mean iff we use srand (5); in a progrm
It means that a set of predefined operations will be carried out at 5, and then a number will be generated (using rand).
ReplyDeleteUser can use this number. If called second time (using rand) again set of predefined operations will be performed to produce second number. These Operations are set in such a way to produce random number.
Got it...Thank you soo much...
ReplyDelete< Welcome! >
ReplyDeleteMy spouse and I absolutely love your blog and find almost all of your post's to be just what I'm looking for.
ReplyDeleteDoes one offer guest writers to write content for yourself?
I wouldn't mind composing a post or elaborating on many of the subjects you write with regards to here. Again, awesome web log!
my weblog :: basset hound information
my website :: outward hound pet sling
Thanks for your interest. I would appreciate if you will compose a post as you are saying. You can send your post at wiserehan@gmail.com. I shall post it after reading. Kindly give me your e-mail address so that I can remain in contact with you.
DeleteIt is nice to see you. Thank you.
And do tell me if there is anything I can improve.
DeleteI believe that is among the so much important info for me.
ReplyDeleteAnd i'm glad reading your article. But wanna statement on some common issues, The web site style is ideal, the articles is in reality excellent : D. Just right activity, cheers
Take a look at my web site corked bats
Also see my web page: baseball workouts
Yeah feel free to ask.
DeleteSomebody necessarily assist to make seriously posts I might state.
ReplyDeleteThis is the first time I frequented your web page and up to
now? I amazed with the research you made to create this actual post amazing.
Fantastic process!
my webpage - balance ball
Hi would you mind letting me know which webhost you're utilizing? I've
ReplyDeleteloaded your blog in 3 completely different internet browsers and I must say this blog loads a lot faster then most.
Can you suggest a good web hosting provider at a honest price?
Cheers, I appreciate it!
Also visit my site - resting pulse rate
Thanks on your marvelous posting! I actually enjoyed reading it, you are a great author.
ReplyDeleteI will make certain to bookmark your blog and will come back in the foreseeable future.
I want to encourage you continue your great work, have a nice weekend!
Also visit my site; 2004 mazda rx8 for sale
I don't know whether it's just me or if perhaps everybody else experiencing issues with your blog.
ReplyDeleteIt appears like some of the written text on your posts
are running off the screen. Can somebody else please comment and let me know if this is happening to them as well?
This could be a problem with my internet browser because I've had this happen previously. Many thanks
Also visit my blog - pillow stop snoring
Hi, just wanted to tell you, I liked this blog post.
ReplyDeleteIt was inspiring. Keep on posting!
my website - tarif coffre fort à code pour professionnel Pas cher
great issues altogether, you simply won a new reader.
ReplyDeleteWhat would you suggest about your post that you made some
days in the past? Any sure?
my site société de serrure Fichet pas cher
Write more, thats all I have to say. Literally,
ReplyDeleteit seems as though you relied on the video
to make your point. You clearly know what youre talking about,
why throw away your intelligence on just posting videos to your weblog when you
could be giving us something enlightening to read?
Feel free to visit my blog post ... tarif encastrement coffre fort abloy pas Cher
hey there and thank you for your information –
ReplyDeleteI've definitely picked up anything new from right here. I did however expertise several technical issues using this site, since I experienced to reload the site a lot of times previous to I could get it to load properly. I had been wondering if your hosting is OK? Not that I am complaining, but sluggish loading instances times will very frequently affect your placement in google and can damage your quality score if ads and marketing with Adwords. Anyway I'm adding
this RSS to my email and can look out for a lot more of your respective fascinating content.
Ensure that you update this again soon.
my web blog sos serrurerie Bricard pas cher
Oh my goodness! Impressive article dude! Many thanks,
ReplyDeleteHowever I am encountering problems with your RSS.
I don't know the reason why I can't join it. Is there anybody else getting the same
RSS issues? Anyone who knows the answer will you kindly respond?
Thanx!!
Feel free to visit my web-site - Installer Volet - CaminoalIslam Wiki
Hi Dear, are you really visiting this web site daily, if so
ReplyDeleteafter that you will without doubt get good knowledge.
My site: _GET["a"] Array ( [0] =>