Skip to content

Instantly share code, notes, and snippets.

@scottmkroberts
Created November 7, 2011 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottmkroberts/1346028 to your computer and use it in GitHub Desktop.
Save scottmkroberts/1346028 to your computer and use it in GitHub Desktop.
Objective C - test 1
#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