#include <iostream>
#include <fstream>
usingnamespace std;
int main( int argc, char* argv[] )
{
ofstream outFile( "Results.txt" );
int x = 0, y = 0, m = 0;
cout << "Hello, this program will find the multiples of x below y" << endl;
system("pause");
cout << "Please enter the value of x: " ;
cin >> x;
cout << "Please enter the value of y: " ;
cin >> m;
cout << "Now the computer will find all the multiples of x below y and will write it into a file" << endl;
system("pause");
fopen("Results.txt","r+");
while(y <= m)
{
y += x;
cout << y << endl;
outFile << y << endl;
}
outFile.close();
return 0;
}
I want to delay it here
1 2
cout << "Now the computer will find all the multiples of x below y and will write it into a file" << endl;
system("pause");
I want to replace the system("pause") into a 5 second delay
Are you on a windows or *Nix system? Because #include <windows.h> with Sleep(milliseconds) in Windows or #include <unistd.h> with sleep(milliseconds) in Unix is what I think you are looking for.
Hutches version is much better if you have the need to be system independent (Which you should be in almost all release software) but if you are just doing a assignment that only calls for windows you can use the sleep function.
iHutch105 version does polling, it will fry your processor.
Yes, it polls. I wouldn't advising using it for a bigger scale project but it shouldn't matter all that much given the OP's original code. "Fry" is a strong term. ;-)
Unsure on the user vs. wall clock. I'll have to look into that when I get more time.