diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..3973dfb Binary files /dev/null and b/.DS_Store differ diff --git a/TestAssessment/TestViewController.m b/TestAssessment/TestViewController.m index 013428d..b0e00fa 100644 --- a/TestAssessment/TestViewController.m +++ b/TestAssessment/TestViewController.m @@ -18,30 +18,34 @@ @implementation TestViewController This method should return any positive NSInteger (hint: cannot be 0) */ -- (void)shouldReturnAPositiveNSInteger { - +- (NSInteger)shouldReturnAPositiveNSInteger { + NSInteger i = 10; + return i; } /* This method should return any negative CGFloat (hint: cannot be 0) */ -- (void)shouldReturnANegativeCGFloat { - +- (CGFloat)shouldReturnANegativeCGFloat { + CGFloat i; + i = -1.001; + return i; } /* This method should return a falsy boolean Falsey: Something which evaluates to FALSE. */ -- (void)shouldReturnAFalseyBool { - +- (BOOL)shouldReturnAFalseyBool { + return NO; } /* This method should return a single char from a - z */ -- (void)shouldReturnACharAtoZ { +- (char)shouldReturnACharAtoZ { + return 'a'; } /* @@ -49,7 +53,11 @@ - (void)shouldReturnACharAtoZ { 0 - 99 using a loop (. 1 + 2 + 3 + ... + 98 + 99) */ - (NSInteger)shouldReturnSumOf0To100 { - return 0; + NSInteger sum=0; + for(int i =0; i<=99; i++){ + sum+=i; + } + return sum; } /* @@ -57,7 +65,12 @@ Given a c array (int[]) and a count, return the sum of the numbers within the ar (eg. arr[0] + arr[1] ...) */ - (NSInteger)shouldReturnSumOfArrayValues:(int *)arr withSize:(int)count { - return 0; + NSInteger sum=0; + for (int i =0; i1050){ + return 0; + } + int sum = arr[0]; + int holder = sum; + int i=1; + while(sum<=1050){ + holder=sum; + sum+=arr[i]; + i++; + } + return holder; return 0; }