why does the following not run ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prakashvs613
    New Member
    • Sep 2007
    • 1

    why does the following not run ?

    [CODE=cpp]#include <iostream>
    #include <ctime>
    #include <cstdlib>

    using namespace std;

    int main()
    {
    srand((unsigned )time(0));
    int random_integer;
    int lowest=1, highest=10;
    int range=(highest-lowest)+1;
    for(int index=0; index<20; index++){
    random_integer = lowest+int(rang e*rand()/(RAND_MAX + 1.0));
    cout << random_integer << endl;
    }
    }[/CODE]
    Last edited by Ganon11; Sep 23 '07, 09:53 PM. Reason: Please use the [CODE] tags provided.
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by prakashvs613
    #include <iostream>
    #include <ctime>
    #include <cstdlib>

    using namespace std;

    int main()
    {
    srand((unsigned )time(0));
    int random_integer;
    int lowest=1, highest=10;
    int range=(highest-lowest)+1;
    for(int index=0; index<20; index++){
    random_integer = lowest+int(rang e*rand()/(RAND_MAX + 1.0));
    cout << random_integer << endl;
    }
    }
    Is it a compilation error? Did you forget to compile it? A runtime error? Did you
    forget to run it? Did your cat chew on the AC cable? Did you spill coke or whatever
    beverage on your keyboard? What, by Jove, was the error you didn't expect.
    Sorry, Sunday is my psychic day off.

    kind regards,

    Jos

    Comment

    Working...