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

  • Home
  • SEARCH
  • 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 6963549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:48:24+00:00 2026-05-27T15:48:24+00:00

I am looking at the following piece of code: void printd(int n) { if

  • 0

I am looking at the following piece of code:

void printd(int n)
{
     if (n < 0) {
         putchar('-');
         n = -n;
     }
     if (n / 10)
         printd(n / 10);
     putchar(n % 10 + '0');
}

I understand the first if statement fine, but the second one has me confused on a couple of points.

By itself, since “n” is an integer, I understand that n/10 will shift the decimal point to the left once – effectively removing the last digit of the number; however, I am having a little trouble understanding how this can be a condition by itself without the result being equal to something. Why isn’t the condition if ((n/10) >= 0) or something?

Also, why is the ‘0’ passed into the putchar() call?

Can someone tell me how it would read if you were to read it aloud in English?

Thanks!

  • 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-05-27T15:48:25+00:00Added an answer on May 27, 2026 at 3:48 pm

    The n / 10 will evaluate to false if the result is 0, true otherwise. Essentially it’s checking if n > 10 && n < -10 (the -10 doesn’t come into play here due to the n = -n code)

    The + '0' is for character offset, as characters ‘0’-‘9’ are not represented by numbers 0-9, but rather at an offset (48-57 with ascii).

    Can someone tell me how it would read if you were to read it aloud in English?

    If you’re talking about the conditional, then I would say “if integer n divided by 10 is not zero”

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

Sidebar

Related Questions

I have been looking for solutions and found the following piece of code. But
I have the following piece of code and I'm looking to replace the Price
I have the following piece of code in PHP. I'm looking for the best
I was looking at the following code I came across for printing a string
I was looking at the following code in python: for ob in [ob for
What is equivalent pythonic implementation for the following simple piece of code in Matlab.
Okay, I am having trouble with the following piece of code (in a header
I am looking for a way i can use code snippets but safely insert
I hope someone can help. The following piece of php code (see below) is
I was looking at a piece of code today and notice that this particular

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.