Amazon.com Widgets Chapter 5 exercise 8
Welcome, Guest. Please login or register.
Did you miss your activation email?
June 20, 2013, 12:15:39 AM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Old Stuff
| |-+  Answers to Exercises
| | |-+  Chapter 5
| | | |-+  Chapter 5 exercise 8
Pages: [1]   Go Down
Print
Author Topic: Chapter 5 exercise 8  (Read 570 times)
sangsudo
Newbie
*
Posts: 12






« on: November 09, 2009, 11:12:36 PM »

This community is so supportive!. Here is my crack at exercise 8.

Code: (Objective-C)
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int n , addSum, remainder;
addSum=0;
remainder=0;

NSLog(@"Type in a number, any number");
scanf("%d",&n);
NSLog(@"Now we will add these two integers together");
while (n!=0) {
remainer= n%10;
addSum=addSum+remainder;
n/=10;
}
NSLog(@"The answer is %d",addSum);

    [pool drain];
    return 0;
}
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.