Hello Everyone,

I'm a first year, going on second year, chemical physicist and over the summer I've been tasked with writing a programme in C. I've not had any experience of programming before and we've only had five lectures and been given some very rudimentary notes. So I've been reading around and having a go at some basic bits and then had a stab at my assignment. Now I've come unstuck. I'm supposed to be creating a programme that allows me to generate a set of random numbers between 0 and 1 and then 'bin' them in an array and then be able to read how many random numbers are in each bin to calculate the distribution of the numbers, presumably to find out whether they're actually random or not! So here's what I've written so far:

I'm at this point trying to get the random numbers into the array but I can't seem to get it to work. I don't want a set of code just some suggestions on how to get this to work, I apologise if my code offends anyone but hey, first time!!! Cheers guys.Code:/* * Organization: Dept. of Physics of Bristol University * Programmer: Sam Briggs * Date: 27/08/11 * * Purpose: Assesed Exercise; Distribution of Random Numbers */ #include <stdio.h> #include <stdlib.h> #include <math.h> #define N 10 //Define size of array to bin data int main() //Main Function Invocation { int q, i, j; //Create Array Subscript integer variable double x; int databins[N][N]; //Create Array to bin data for (q=0; q<N; q++) { x=rand()/(double)RAND_MAX; //Generate Random Number between 0 and 1 printf("The random numbers are: %d:%f\n", q,x); if ((x>=0)&&(x<(N/10))) { databins[0][i]=x; } else if((x>=(N/10))&&(x<((N/10)*2))) { databins[1][i]=x; } else if((x>=((N/10)*2))&&(x<((N/10)*3))) { databins[2][i]=x; } else if((x>=((N/10)*3))&&(x<((N/10)*4))) { databins[3][i]=x; } else if((x>=((N/10)*4))&&(x<((N/10)*5))) { databins[4][i]=x; } else if((x>=((N/10)*5))&&(x<((N/10)*6))) { databins[5][i]=x; } else if((x>=((N/10)*6))&&(x<((N/10)*7))) { databins[6][i]=x; } else if((x>=((N/10)*7))&&(x<((N/10)*8))) { databins[7][i]=x; } else if((x>=((N/10)*8))&&(x<((N/10)*9))) { databins[8][i]=x; } else if((x>=((N/10)*9))&&(x<N)) { databins[9][i]=x; } else { databins[j][i]=0.0; } } printf("\nHere follow the Databins:\n\n"); for (i=0; i<N; i++) //Print All Array Entries { for (j=0; j<N; j++) { printf("%f", databins[j]); } printf("\n"); } return 0; }