help me out, it says rand cant be used as a fuction when compiling.

#include <cstdlib>
#include <iostream>
#include <math.h>
#include <ctime>


using namespace std;


int main(int argc, char *argv[])
{
    int i,rnumber,number,power,base,rand;
    int randomise();//initialises random number generator
    srand(time(0));
    cout<<"ten random numbers from 0 to 99\n\n";
    for(i=0;i<10;i++){
                       rnumber= rand()%100;
                       cout<<rnumber<<endl;
                     }
    cout<<"\nusing built mathematics fuctions\n";
    base=3;
    power=4;
    number=81;
    cout<<base<<"to the power"<<power<<"is"<<pow(base,power)<<endl;
    cout<<"the square root of"<<sqrt(number)<<endl;
    number=6;
    cout<<"the absolute value of"<<number<<"is"<<abs(number);
    return 0;

    system("PAUSE");
    return EXIT_SUCCESS;
}

Recommended Answers

All 3 Replies

You declare a variable with the name "rand" and then you try to call the function rand. It thinks you are trying to use the int variable as a function. Delete the rand variable or at least rename it and it works fine.

And why are you calling the function randomize and srand()?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.