Knight313 wrote:So I was looking at the output of that code and it seems your result is like a sin wave that eventually flattens out at a value of 53181, that number is simply a number that when input into your function results in the same number.
In a program that I wrote I had a problem where my program would ask the same number over and over agian. I needed to write extra logic to help catch those problems and take care of them. I think you are going to simply need to come up with a better function to randomize your number. I have never done "random numbers" before but I googled it once and found a bunch of articles on it. I would suggest reading how someone else did it.
Thats just a quick look at it, im no expert either so maybe someone else can give you a better answer.
Thanks for the suggestion
i tries srand(time(0)) and thn rand()
and it worked
- Code: Select all
#include "stdafx.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
srand(time(0));
for (int count=0;count<10;count ++)
{cout <<rand()%100<<"\t";
if ((count+1) %5==0) cout<< "\n";}
char f;
cin>>f;
return 0;
}
now i'm trying to figure out how to assign the random number to a variable
