How we can randomly generate and store the age of N employees in Arrays plssssss
alex k
0
Newbie Poster
Recommended Answers
Jump to PostYou can use while loop and terminate it with -1, if the number of employees is not known, else you can just use a neat for loop. And for random number generation have a look at this link:
http://www.cplusplus.com/reference/clibrary/cstdlib/rand/If you have any code written, then post …
Jump to PostIf you want an undetermined amount of employees, you won't be able to use an array. Use a vector, instead.
Jump to Postpsuedo-code:
create randomAges[N] = {0}: seedRng(); for (i = 0 : N){ randomAges[i] = rand(); }
Jump to Postfor ( i = 0; i != NULL; i++ ) // use stdlib.h or stdio.h ( may be cstdlib or cstdio as the case may be) *( age + i ) = rand();
This will never run. In a proper C++ implementation NULL is defined as int …
All 16 Replies
Software guy
6
Junior Poster
Fbody
682
Posting Maven
Featured Poster
packetpirate
0
Junior Poster in Training
mrnutty
761
Senior Poster
manojwali
-4
Light Poster
Fbody
682
Posting Maven
Featured Poster
manojwali
-4
Light Poster
Fbody
682
Posting Maven
Featured Poster
manojwali
-4
Light Poster
manojwali
-4
Light Poster
mrnutty
761
Senior Poster
Fbody
682
Posting Maven
Featured Poster
manojwali
-4
Light Poster
manojwali
-4
Light Poster
Fbody
commented:
Drop it already. For someone that doesn't like arrogant people, you're sure arrogant.
+0
Fbody
682
Posting Maven
Featured Poster
manojwali
commented:
just using vs 2008 which has a CRL an non standard extension, so get irretated as give me negative reputation points.
+0
manojwali
-4
Light Poster
Fbody
commented:
CLR is irrelevant to the situation. Besides, Code::Blocks doesn't use CLR, that's why I mentioned it. Get your facts straight.
+0
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.