good day to all!
i have a project all about color guess game.
i just want to learn about using random functions in words because usually i only see random numbers.
anyone can help me to create a source code that will randomize words? thank you! turbo c only.

Recommended Answers

All 24 Replies

i just want to learn about using random functions in words

do you need help in retrieving words from a file or generating random strings

turbo c only.

wouldn't you rather use a modern compiler than this antique

Yes, we can help. Ask a question...

my professor told me to use turbo c only, please help me on how to make a source code of like a color guessing game, i will input a color and the computer will randomly choose a color(but only red, blue, green, white, pink and yellow). hope you can help thank you!

i just need a super simple and basic codes :) thanks

I still don't see a question. All we can do with the info you gave us is write it for you. That's not how we work here. What problems are you having? What have you tried? What don't you understand?

And, just so you know, your professor is 30 years out of touch with programming. He's forcing you to use the equivalent of spears when the rest of the world uses lasers. He's teaching you something you'll never use in the real world.

i just need a super simple and basic codes :) thanks

Ahh, I see. You do want us to write it for you. Sorry, not going to happen. We don't get the grade and you won't deserve it. And what would your professor say when he finds out?

no i dont need the whole code, i tried to use randomizing in words but it won't work so i just want to learn to use it in words and i tried to research but they are using other compilers already, i just want to know how to use randomize in words?

randomizing in words

still vague, can you tell if you meant
generate letters randomly to form a word,
retrieve words randomly from a file or array,
or something else??

i have no idea about using randomize functions because it is still not taught to me, can it be used to randomize words? like it will randomly choose words and output it?

but can it be used without using words from a file? just only using turbo c itself.

the only randomizing funtion for C I know is exclusive for integers only.
What you could do is create and store the words in an array or file then use the rand function to generate a number, the word whose index matches the number will be retrieved

even i will just use the colors? not the colors but the words red,blue,green,yellow,white,pink only

but can it be used without using words from a file? just only using turbo c itself.

either create an array containing them or randomly choose letters to fill a string

even i will just use the colors? not the colors but the words red,blue,green,yellow,white,pink only

if those are the only words you'd need then it's more easy to store them in an array and using the rand() function to generate a number, check the word whose index matches the generated number and retrieve it

can i assign an integer value to a word in turbo c?
example for blue=1 then red=2 green=3 yellow=4 white=5 pink=6? then i will randomize from 1 to 6 only then if the output is 1 then it will show blue. can i do that?

you could (well not literally assign but the use of conditions),though that's gonna be a lot of if-else statements
using an array and looping through the indexes will simplify this

okay can you give me atleast 1 example of how can i assign a number to a word? please? so i can have a guide.

btw thank you very much for your help! it is a big help to me.

by "assign" I mean it's more on conditions where a string variable color will get it's value from the generated number using if-else statements
example would look something like this:

if(numbergenerated == 1)
    color = "blue";
else if(numbergenerated == 2)
    color = "red";

but seriously take the array advice it's gonna lessen the code cluster

ohh i see how. okay i'll try both. THANK YOU ma'am/sir! have a good day!

now with arrays it will look something similar to this:

char GuessColor[10];
char color[10][10] = {"blue", "green", "red", ...};
for(i = 0; i < strlen(color[i]); i++)
    if(GeneratedNumber == i)
        strcpy(GuessColor,color[i]);

printf("%s", GuessColor);

simple

oh last question, can you give an example for randomizing letters?

there are 2 ways I can think of right now to do this:
the first is similar to the examples I gave you using arrays or conditions but instead of using words you's use characters
next is printing the ascii equivalent of the generated number with the scope of the starting and ending character ascii values
ex. of the latter

int generatednumber = 97;
printf("%c", generatednumber);

ohh i see now, now i can finish my project! thank you a lot!

Hello, I would like to make a suggestion with regards to randomising words about colours. Sorry I cannot suggest a programme, as I dont have any idea of programming that most of you do, because my field is Subtle Energy, however, I too wanted a Random Generator for words. I found one on the internet which you can use, to try out your theory on colour. You will find it on Random.Org it is called a List Generator, however, there is a restriction as to how many tries you have a day. Type in all the words you require, if you need a number with them, type them in after the name, because they initially use this True Random Generator on numbers, however the name doesnt make any difference. I am using 300 words or sentences, it will select each one in order of randomness. If you need these colours for a specific purpose, then contact me, I can help you with that.
Flowerlady

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.