This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
user:asowers:fun_with_time [2012/12/03 18:05] – [code] asowers | user:asowers:fun_with_time [2012/12/03 18:10] (current) – [Time for fun] asowers | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====Welcome==== | ||
+ | It's possible to create simple games with the time.h header file. | ||
+ | ====Time for fun==== | ||
+ | Students from college campuses across America are familure with the game "Power Hour." | ||
+ | The game entails preforming a certain action every minute for one hour. Using C programming, | ||
+ | |||
+ | ====code==== | ||
+ | <code c> | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | printf(" | ||
+ | int i; | ||
+ | for(i = 0; i <= 60; ++i) | ||
+ | { | ||
+ | printf(" | ||
+ | sleep(60); | ||
+ | printf(" | ||
+ | } | ||
+ | printf(" | ||
+ | return 0; | ||
+ | } | ||
+ | </ | ||
+ | Compilation and execution: | ||
+ | <cli> | ||
+ | andrew ~/src $ gcc powerhour.c -o powerhour | ||
+ | andrew ~/src $ ./powerhour | ||
+ | Begin power hour! | ||
+ | Minute Number: 0 | ||
+ | Drink! | ||
+ | Minute Number: 1 | ||
+ | Drink! | ||
+ | Minute Number: 2 | ||
+ | (etc) | ||
+ | </ | ||
+ | ====Final thoughts==== | ||
+ | Programming is about more than solving mundane problems; it's also about improving peoples quality of life through simplex enhancements. |