Amazon.com Widgets The shortest 6.5 exercise variant!
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 24, 2013, 03:08:09 PM
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 6
| | | |-+  The shortest 6.5 exercise variant!
Pages: [1]   Go Down
Print
Author Topic: The shortest 6.5 exercise variant!  (Read 473 times)
Jemcik
Newbie
*
Posts: 22



Email




« on: November 19, 2011, 04:34:48 AM »

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

int main (int argc, const char * argv[])
{
    @autoreleasepool
    {
        long long int num;
        printf("Enter an integer number (max 17 digits): ");
        scanf("%lli", &num);
        BOOL sign = num < 0 ? TRUE : FALSE;
        
        for (sign ? num = -num : num; num; num /= 10)
            printf("%lli", num%10);
        sign ? printf("-\n") : printf("\n");
    }
    return 0;
}

P.S. Some explanation needed?
« Last Edit: November 19, 2011, 06:08:28 AM by Jemcik » Logged
alexsom
Jr. Member
**
Posts: 63



Email




« Reply #1 on: January 20, 2012, 09:10:05 PM »

It looks good. Yes, I would like some explanations if you don't mind. thanks
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.