I know this post belongs on the plain ol' C++ board, but my posts dissappear on that board! (no mistake).
Ok, anyways, I need to know if this program I am about to show you is accurate to clock processor speed. Is the processor really working hard?
PHP Code:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
#include <iostream.h>
int rand(void);
int main()
{
time_t difference;
int x = 0;
int y = 0;
int z = 0;
int actualZ;
printf("Input the end of the range please (0 - x): x = ");
cin>>z;
actualZ = z + 1;
time_t StartTime = time(NULL);
while(!kbhit())
{
x = rand() %actualZ;
printf("%d",x);
y++;
}
time_t EndTime = time(NULL);
system("cls");
difference = EndTime - StartTime;
printf("A random number between 0 and %d ",z);
printf("was generated %d times ",y);
printf("in %d seconds",difference);
while(!kbhit());
return 0;
}