Am I writing this correctly? I'm trying to get a random point on a circle by getting a random angle by getting a random number between 0 and 1 then multiplying it by 2PI.
Make sure you only call srand()once at the start of your program, and then never again. Also, RAND_MAX is an integer so you have an issue with integer division (you'll always get 0).
No. rand() / RAND_MAX — integer division, almost always 0.
Do not use floats, unless you have a good reason to use exactly them. Native floatiing point type for C++ is double.
Prefer C++11 random facilities to C random functions (which have a great chance to be removed from C+ completely in future).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
#include <random>
constexprdouble PI = 3.14159265358;
int main()
{
//Not the proper initialization, but will suffice for small test programms
std::mt19937 rng( std::random_device{}() ); //Unless you are using MinGW
std::uniform_real_distribution<> dist(0, 2*PI);
//Random angle: randAngle = dist(rng)
std::cout.precision(2);
std::cout.setf(std::ios::fixed);
for(int i = 0; i < 10; ++i)
std::cout << dist(rng) << '\n';
}