Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8488407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:31:37+00:00 2026-06-10T21:31:37+00:00

From the Programing in Objective C (Kochan): Program 5.8 prompts the user to enter

  • 0

From the “Programing in Objective C” (Kochan):

Program 5.8 prompts the user to enter a number and then proceeds to display the digits
from that number from the rightmost to leftmost digit.

// Program to reverse the digits of a number
#import <Foundation/Foundation.h>

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

{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int number, right_digit;

NSLog (@"Enter your number.");
scanf ("%i", &number);

while ( number != 0 ) {
right_digit = number % 10;
NSLog (@"%i", right_digit);
number /= 10;
}

[pool drain];
return 0;
}

My question is: what happening when user types in single digit number- 1 to 9 ? I couldn’t find any material about such case.
After compilation the program just proceed with returning that single digit. Why is that?
I was trying to come up with code for this task and spend literally 2 hours, trying to incorporate loops and decision making for this ” if number is single digit” problem. And the solution was so ignorant!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:31:38+00:00Added an answer on June 10, 2026 at 9:31 pm

    The modulo operator gives you the remainder after a division. If yo have 8 % 10 the result is 8 because 8 / 10 is 0 with a remainder of 8. You get the same result if you have 38 % 10, 38 / 10 is 3 with a remainder of 8.

    edit:
    Modulo is what you normally learned as the first division in elemantary school. It is funny that the most children have no problem with modulo but when they learned that 8 / 10 is 0.8 they have problems understanding modulo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning from Programing in Lua by Roberto Ierusalimschy, and I found that
From Objective C Programming Guide (Under the "Object Messaging" section), Methods that take a
This is an example from The Objective-C 2.0 Programming Language. I was just wondering,
I am learning C from ' Programming in C' by Stephen Kochan . Though
I don't understand why authors said that Code Listing 9.1 from Programming in Scala
I have been reading about bit operators in Objective-C in Kochan's book, Programming in
I'm really new to programming with objective c and so I hope that you
(programming in iPhone objective-C) I have a class level NSString* that I create, add
I'm programming on objective-c. I've removed all files from MyTarget -> Build Phases ->
I just recently made the move to Objective-C. I am doing some exercises from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.