Who knows C++?
16 years ago
I need someone to help me with a C++ script if anyone knows it.
I need a script that that displays “hello world” 10 seconds after the script is executed. I also need it to use a ‘while’ loop.
I need a script that that displays “hello world” 10 seconds after the script is executed. I also need it to use a ‘while’ loop.
Also... you cannot accurately predict "10 Seconds" using a while loop and a randomly chosen "big ass number" to crunch through.
I recommend throwing out the while loop idea and just using : Sleep(10000); //10k miliseconds = 10 seconds)
then putting your message code underneath.
Why are you doing this anyways? If its for a course... i recommend you actually learn how to do this.
But here's the source you'd need to get his to work:
#include <iostream>
#include <time.h> // I think you need this, may not for the sleep function
int main()
{
int Seconds = 10;
while(Seconds < 0)
{
Sleep(1000); // sleep for one second
Seconds--; // take a second off the counter
}
printf("Hello World! \n");
return 0;
}
alternatively to printf is [cout << "Hello World!" << endl;]