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 8040921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:03:11+00:00 2026-06-05T04:03:11+00:00

Possible Duplicate: What is the valid range for program return value in Linux/bash? Here

  • 0

Possible Duplicate:
What is the valid range for program return value in Linux/bash?

Here is a simple c program:

#include <stdio.h>
int main(){
    int a=0, b=100;
    while(a<=b){
        printf("%d\n",a);
        a+=10;
    }
   return a;
}

Checking the return value on linux gives 110 which is expected as the last expression evaluated in the program is assignment of 110 to a;
But when I replace b=100 with something greater than 256 say b=260; the return value is 14 and not 270 which was expected.
Why does returned value wrap around 256 when main is supposed to return integer whose range is far more than 256?

  • 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-05T04:03:13+00:00Added an answer on June 5, 2026 at 4:03 am

    Unfortunately, its the case in Unix based systems. That you cannot return a value >255 from main even though you specify the return type as int. Read here.

    Windows is more permissive in the sense that it uses 32-bit signed integers as exit codes

    Also, you cant assume that the return value shall always be the value of the last expression evaluated. If there is no explicit return statement, how the return value is inferred is architecture dependent. For example, on ARM systems, its the value in R0 ( or R0+R1 sometimes) register and on x86 systems its the EAX register.

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

Sidebar

Related Questions

Possible Duplicate: #include anywhere For the respective languages, is the following valid (acceptable programming
Possible Duplicate: Is it valid to replace with // in a <script src=“…”>? I've
Possible Duplicate: What are valid values for the id attribute in HTML? Underscores seem
Possible Duplicate: Cross-thread operation not valid I am trying to close the base of
Possible Duplicate: Cross-thread operation not valid: Control accessed from a thread other than the
Possible Duplicate: Getting Cross-thread operation not valid Cross-thread operation not valid I am trying
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result I'm getting
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result I am
Possible Duplicate: What does map(&:name) mean in Ruby? What does the &:valid? found in
Possible Duplicate: Cross-thread operation not valid: Control accessed from a thread other than the

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.