I have a problem with this code, when i try to run it the result is a lot of 0.00000. I need to generate random set of 2d points. I am new, so maybe what i wrote has no sense. Can someone help me?
#include <stdio.h>
#include <math.h>
#include <string.h>
#include<time.h>
#include <stdlib.h>
void main()
{
srand((unsigned)time(NULL));
int x[] = { rand() % 10 + 0 / (double)RAND_MAX + 0};
int y[] = { rand() % 10 + 0 / (double)RAND_MAX + 0};
for (double n = 0; n < 10; n++)
{
It's very simple. If xsign or ysign is true by random chance(really pseudo chance), you turn the coordinate(whether it's x or y) to a negative. You also don't want to modify the number so you simply multiply it by 1.
Since you're outputting two coordinates, you need two arguments in your printf function. In this case, two %d %d. The 3 is to set the width of the output to make it look neat.