CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Feb 2009
    Posts
    35

    Number generator between 0-100

    I created a program which takes a number between 0-100 to calculate probability and i created a module but when i call for it it brings me numbers out of my requested range, please tell me what i am doing wrong,

    I have
    i=0
    h=100

    This is my module

    Code:
    double probability (int h, int i)
    {
    	return ((double) rand () / RAND_MAX) * (h-i) + i;
    }
    Thanks in advance
    Last edited by peste19; April 1st, 2009 at 04:28 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured