Hello everyone
I have a task to generate 300 random particles in a 2-D plane ( 1 x 1)
The steps are given as :
1. Generate two numbers
2. Scale them to max dimension
3. Repeat 1 and 2 in a 'for loop' to generate 300 particles ans store them in a verctor px and py .
4. get the output
Ok I just created this code but I am confused at some point and need help
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
void main()
{
clrscr();
int a[20][20]; //array for storing ouput numbers
int px,py; // x and y axis
for (px=0; px<20; px++) //x axis with the range of 20
{
for(py=0; py<20; py++) //y axis with the range of 20
{
a[px][py]=rand() %1000 + 1; //Random particles b/w 1 to 1000
printf("a[%d][%d] = %d\n", px,py, a[px][py]); //axis points and particles value
}
}
getch();
}
This code prints the random numbers between 1 to 1000 for the range of 20 x 20 and that will be 400 random numbers , I want to print the 300 random numbers under the area of 1 x 1 meter , so what could be the possible solution ? where I a going wrong