0

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;
}
3
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by lizziekadango
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.