Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,260 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,549 people online right now. Registration is fast and FREE... Join Now!




rand()

 
Reply to this topicStart new topic

rand()

jaclyn_85
6 Nov, 2006 - 04:49 PM
Post #1

New D.I.C Head
*

Joined: 16 Sep, 2006
Posts: 17


My Contributions
I need to make a function that outputs y and n randomnly using rand().
The only info i can find for using rand() is with numbers. not characters. any help please?
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Rand()
6 Nov, 2006 - 04:56 PM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,985



Thanked: 44 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
That is because the rand function only returns a number. What you need to do is randomly pick a number between 1 and 2. If 1 is picked then output the letter 'y', if 2 is the number picked then output the letter 'n'.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 06:49PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month