welcome.
please put code in code tags, the <> on the editor or
blocks.
a,b,c and d are pretty much the same problem just detailed out (confusingly to a beginner perhaps). Your loop termination logic needs repairs; there are a few ways to do it, the suggested ones are a simple approach that I think will work. Fix the logic, however it makes sense to you.
e is related but probably worth its own comment. Do a-d first, then circle back here after.
Don't even touch the array and function until you have done the above. One change at a time, test and debug it, then try the next item. Take it slowly. Keep a backup of your code in case you need to undo changes.
not critical, but you are using C or C++ 1998 and earlier headers. That is, your code looks like it is nearly 30 years old.
#include <stdio.h> //should be <cstdio>, but this is not a good header to use in most c++ programs.
#include <math.h> //should be <cmath>
#include <stdint.h> //<cstdint>
#include <stdlib.h> //<cstdlib> also not great in c++ programs
#include <time.h> //<ctime> or better, <chrono>
and consider <random> instead of rand(), which is C and terrible.
typically you use double always and float never, unless you have a good reason (interface to something that uses float or space critical needs where the extra space isnt available or want to save space).
c++ uses cout, cin and not printf/scanf. Those are for C programs, or very old C++ code, or special purpose code.