Need a little C programing help

Discussion in 'OT Technology' started by Kieffer87, Sep 14, 2006.

  1. Kieffer87

    Kieffer87 Orly OT Supporter

    Joined:
    Sep 23, 2005
    Messages:
    1,491
    Likes Received:
    0
    Location:
    Where the Green Grass Grows
    I'm trying to work on my C homework right now I just started the class 3 weeks ago so bare with me please. We need a program with an inner and outer loop. The outer needs to run 10 times and the inner runs 100000 times for every outer im guessing. and its going to randomly generate a number using the time. Basically I can't figure out how in the hell to set up the outer loop. Any ideas or good sites to explain it?
     
  2. Coottie

    Coottie BOOMER......SOONER OT Supporter

    Joined:
    Jun 6, 2006
    Messages:
    32,407
    Likes Received:
    0
    Location:
    OKC
  3. Kieffer87

    Kieffer87 Orly OT Supporter

    Joined:
    Sep 23, 2005
    Messages:
    1,491
    Likes Received:
    0
    Location:
    Where the Green Grass Grows
    Thank You very much.
     
  4. kilamasta

    kilamasta New Member

    Joined:
    Aug 14, 2006
    Messages:
    108
    Likes Received:
    0
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>

    int main(int argc, char *argv[])
    {
    int i,j;

    int max = 10;
    int min = 0;
    srand(time(NULL));

    for( i=0;i<10;i++)
    {
    for( j=0;j<100000;j++)
    {


    printf("%d\n",(int) (max + ((float) rand() / RAND_MAX * (max - min + 1))) );
    }
    }

    getchar();
    return 0;
    }
     
    Last edited: Sep 15, 2006

Share This Page