Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ Random # Generation

Name: Anonymous 2006-11-22 1:36

So, how can I randomly generate numbers into a program like this?

double triangleArea(double t)
{
        double base;
        double height;
        double answerT;
        cout << "Enter the Base of the Triangle: ";
        cin >> base;
        cout << "Enter the Height of the Triangle: ";
        cin >> height;
        answerT = .5 * base * height;
        cout << "The Area of the Triangle is: " << answerT << "." << endl;
        return answerT;
}

This is inside a function, because I have selection of multiple functions inside main. I want the program to randomly generate numbers into the function itself so the user doesn't have to.

I tried to change the cin's to base = rand(); and height = rand();...this doesnt work...in fact, even if i take the cout's out of the function, it still cout's those strings...WTF?

Name: Anonymous 2006-11-22 11:13

in fact, even if i take the cout's out of the function, it still cout's those strings...WTF?
Did you fail to recompile after editing the code?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List