Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: random number generation  (Read 6732 times)

0 Members and 1 Guest are viewing this topic.

#groff -Tascii -man yakub

  • Guest
random number generation
« on: June 19, 2008, 06:09:59 AM »
i want a random number generation program between 0-5 using c language

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: random number generation
« Reply #1 on: June 19, 2008, 06:42:26 AM »
Quote
i want a random number generation program between 0-5 using c language

Have you checked if C has a random number function? This link might be a little dense, but what caught my eye was the KISS generator.

 8)

As long as this thread is about wishlists, I want a Lamborghini Gallardo!

The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

#groff -Tascii -man yakub

  • Guest
Re: random number generation
« Reply #2 on: June 19, 2008, 07:12:20 AM »
sorry i want an exact program
   i am not understanding anything from your given link
   thank you for your replay

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: random number generation
« Reply #3 on: June 19, 2008, 09:32:04 AM »
You really need a contract programmer. This little bit of code will show you method, however it needs some changes to meet your requirements.

Code: [Select]
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int array[16] = {0};
int x;
int y;
int m;
int n;
srand(time(0));
for(x = 1; x < 17; x++)
{
array[x] = rand()%17;
}
for(x = 1; x < 17; x++)
{
for(y = 0; y < 17; y++)
{
if( x != y)
{
if(array[x] == array[y])
{
array[x] = rand()%17;
if(16 == array[x])
{
array[x] == ' ';
}
}
}
}
printf("%5d", array[x]);
if(x%4 ==0)
printf("\n");
system("PAUSE");
return 0;
}}

This program can be compiled with the Tiny C Compiler

Good luck.  8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

HypercamJ



    Beginner

  • Oops =0
    Re: random number generation
    « Reply #4 on: June 19, 2008, 11:10:34 AM »
    You really need a contract programmer.
    Yo should sign up to be one.   ;)
    ╔░░░░░░░░╗
    _Hypercam⌡_
    ╚░░░░░░░░╝