Created
July 22, 2012 16:36
-
-
Save taiki45/3160234 to your computer and use it in GitHub Desktop.
Sample programs for STS
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
#include <stdio.h> | |
int sum_to_100(void); | |
int product_to_10(void); | |
int main (int argc, const char * argv[]) | |
{ | |
sum_to_100(); | |
product_to_10(); | |
return 0; | |
} | |
int sum_to_100(void) | |
{ | |
int i, sum =0; | |
for (i=1; i<=100; i++) { | |
sum += i; | |
} | |
return sum; | |
} | |
int product_to_10(void) | |
{ | |
int i; | |
int sum = 1; | |
for (i=1; i<=10; i+=2) { | |
sum *= i; | |
} | |
return sum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment