Amazon.com Widgets Exercises 2 - 6
Welcome, Guest. Please login or register.
Did you miss your activation email?
August 02, 2014, 01:34:59 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 2
| | | |-+ Exercises 2 - 6
Pages: [1] Go Down
Print
Author Topic: Exercises 2 - 6 (Read 1847 times)
JackRabbit
Jr. Member
**
Posts: 54



Email




on: November 18, 2011, 12:44:46 AM

Here they are.

Exercise 2

//
//  exercise 2
//
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{

    @autoreleasepool
    {
        // this program will display the text in Exercise 2
        NSLog(@"In Objective-C, lowercase letters are significant.\n
        main is where program execution begins.\n
        Open and closed braces enclose program statements in a routine.\n
        All programs statements must be terminated by a semicolon. "
);
    }
    return 0;
}



Exercise 3

Testing . . . .
. . . . 1
. . .2
. .3



Exercise 4

//
//  Exercise 4
//


#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
    @autoreleasepool
    {
        // declare the variable dif.
       int dif;
        dif = 87-15;
        
        NSLog(@"15 from 87 equals %i.", dif);
    }
    
    return 0;
}


Exercise 5

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{                                                  should be a curly bracket
   @autoreleasepool
  {
   int sum;                                       INT should be lower case
         // COMPUTE RESULT                 needs a double slash "/*"is for inline comments & doesn't need a double slash at the end.
   sum = 25 + 37 19;                       there should be a semicolon at the end
   //DISPLAY RESULTS                        needs a double slash and doesn't need and ending slash
   NSLog (@The answer is %i, sum);  should be double quotes and missing comma
   }
return 0;
}


Exercise 6

The result is 95




Am I correct?

JR
Last Edit: November 21, 2011, 09:59:38 PM by JackRabbit Logged
seerex
Full Member
***
Posts: 177


Email




Reply #1 on: November 18, 2011, 04:44:47 AM

At a quick glance i'd say you are all set Smiley good job!

Best Regards
/JBJ
Logged

Best Regards -
J.B.J
If you think i helped you could return the favor Wink

Subscribe to my channel on youtube: http://www.youtube.com/user/JBJProgramming

My apps:
- iTap Fruits (all countries)
- Toilet-Quiz (Denmark only)
- Zoo Kids (Denmark only)
- Diablo Item Database (All countries)
JanryC
Newbie
*
Posts: 9


cabasaganjanry@ymail.com




Reply #2 on: November 18, 2011, 07:32:47 AM

Yes you are! Same here classmate! Wink

good job!
Logged
JackRabbit
Jr. Member
**
Posts: 54



Email




Reply #3 on: November 20, 2011, 10:51:52 PM

Thank you JanOriCab and seerex. I appreciate the encouraging feedback.

And yes, seerex, I have already subscribe to your channel on youtube. Your video's look very helpful.

Now...On to Chapter 3!

JR
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.