User Tools

Site Tools


user:asowers:fun_with_time

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
user:asowers:fun_with_time [2012/12/03 18:04] – created asowersuser: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."(Google is your friend)
 +The game entails preforming a certain action every minute for one hour. Using C programming, this task can be automated. Automation in this instance allows people more time to socialize by taking away the time needed to moderate the game.
 +
 +====code====
 +<code c>
 +#include <stdio.h>
 +#include <time.h>
 +
 +int main()
 +{
 +        printf("Begin power hour!\n\a");
 +        int i;
 +        for(i = 0; i <= 60; ++i)
 +        {
 +                printf("Minute Number: %d\n",i);
 +                sleep(60);
 +                printf("Drink!\n\a");
 +        }
 +        printf("Congratulations, you've survived power hour!");
 +        return 0;
 +}
 +</code>
 +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)
 +</cli>
 +====Final thoughts====
 +Programming is about more than solving mundane problems; it's also about improving peoples quality of life through simplex enhancements.