srand is not declared!

Hello, I am a pure C++ Beginner, I use dev c++ as my compiler.

here is my code. Please take the time to look it over and tell my why its not working :/

#include<iostream>
#include<ctime>
using namespace std;
int main()
{

//declare variables
double number_of_guessing=0.0;
double num=0.0;
double randomNumber=1+rand()%(99-1+1);
srand(int(time(0)));
do
{
cout<<"Please enter a Number"<<endl;
cout<<""<<endl;
cin<<num<<endl;
if(num<randomNumber)
cout<<"The Number You Entered is Too Low"<<endl;
if(num>randomNumber)
cout<<"The Number You Entered is Too High!"<<endl;
if(num=randomNumber)
cout<<"You Have Entered The Correct Number!!"<<endl;
}while(num=randomNumber) cout<<"Play Again?"<<endl;
return 0;
}

srand is in <cstdlib> which you did not include.
http://www.cplusplus.com/reference/cstdlib/srand/

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
http://v2.cplusplus.com/articles/jEywvCM9/
It makes it easier to read your code and it also makes it easier to respond to your post.
Last edited on
If you want to use random numbers you need to include an appropriate library. I suggest <random>. http://www.cplusplus.com/reference/random/ You need to make sure you are using an up to date compiler (which you should be anyway) to use this library.

Why are you using doubles where you could use integers just fine?

cin<<num<<endl;

cin is like this cin >> num;

Also, the endl; instruction should not be in there. You want to output this newline with cout.

Also, if you post code here in future, be sure to use [co de] [/co de] (without the space) tags.
Oh ok Thank you very much. I'll try it.
I'll make sure I also use [co de] next time I post :)
Topic archived. No new replies allowed.