Created
November 7, 2011 20:16
-
-
Save scottmkroberts/1346028 to your computer and use it in GitHub Desktop.
Objective C - test 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
#import <Foundation/Foundation.h> | |
/* Test I had to do, Took me way to long so thought I would draft it up in objective c | |
basically getting the remainder using the % modular type. | |
loop through to 100, if number is divisible by 3 print buzz if its divisible by 5 print fizz and if its both print buzz fizz. Else just print the number. | |
*/ | |
int main(int argc, char *argv[]) { | |
NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init]; | |
printf("Test I had \n"); | |
for (int i = 0; i <= 100; i++) { | |
if(i%3 == 0 && i%5 == 0){ // no remainder | |
printf("buzz fizz \n"); | |
}else if(i%3 == 0){ | |
printf("buzz \n"); | |
}else if(i%5 == 0){ | |
printf("fizz \n"); | |
}else{ | |
printf("%i\n",i); | |
} | |
} | |
[p release]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment