I have to write a program that generate 7 random numbers from 1 to 39 to write condition which don't allows to repeat the same number twice , and to sort them from the smallest to the greatest

in the end to have this result

**** LOTO GAME 7 TO 39 *******

-generated numbers are:
17 19 14 3 37 36 11
-arranged generated numbers are:
3 11 14 17 19 36 37

Program ended, press <enter> for termination ....

what exactly is your question(s) about how to write that program. You will need to use functions srand() and rand() which generates the random numbers, then save the values in an array. Each time a new random number is generated search the array to see if it's already there. If not, then add the number and repeat the process.

There are may ways to sort arrays. Probably the simplest to code is called the Bubble Sort. google for sorting algorithms and you will easily find them.

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.