Last active
August 29, 2015 14:18
-
-
Save mos3abof/2489ee3c9d04ea624770 to your computer and use it in GitHub Desktop.
Count down from 100 to 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A quick solution for the question in this blog post: | |
* http://www.thousandtyone.com/blog/EasierThanFizzBuzzWhyCantProgrammersPrint100To1.aspx | |
* | |
* Took me 30 seconds, without the comments. | |
* | |
* The problem: | |
* Print 100 to 1. | |
* You need to start with "for(int i=0;" and continue from there. | |
* You cannot write anything before "for(int i=0;". | |
* You can't use two loops. | |
* | |
* To compile this file on linux use the following command: | |
* gcc 100_countdown.c -std=c99 | |
* | |
* To run it use this command: | |
* ./a.out | |
*/ | |
#include <stdio.h> | |
int main(void) | |
{ | |
for(int i = 0; i < 100; i++) | |
{ | |
printf("%i\n", (100 - i)); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment