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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:45:12+00:00 2026-06-15T05:45:12+00:00

Recently I tried to write a code that searches for a certain number in

  • 0

Recently I tried to write a code that searches for a certain number in a given n.
The code worked perfectly but when I tried to insert n with more than 10 digits it got realy bad.

Apparently it had nothing to do with the code, I just couldn’t insert more than 10 digits.
I must be missing something…

For example this simple code

#include <stdio.h>

int main()
{
  long int n;

  scanf("%ld", &n);

  printf("%ld", n);

  return 0;
} 

If I feed it 1111111111 it would print the same thing becuase its less than 11 digits
If I try to feed it 11111111111 it would give me something like -1773790777
Why is this happening to me? what am I doing wrong…

  • 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-15T05:45:14+00:00Added an answer on June 15, 2026 at 5:45 am

    I’m guessing you are on a 32-bit machine, which means that the long int is only 32 bits, which means it can hold values between minus 2 billion to plus 2 billion. When you try to enter much more than that, the value wraps over.

    You should start using a 64-bit value like long long int if your compiler supports it.

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

Sidebar

Related Questions

I recently tried to combine SEAM and GWT in a project - but failed
I'm recently tried to make a custom tabcontrol that able to move the tab
Recently I tried to explain some poorly designed code to my project manager. All
I've recently tried to write a small scraping script with Ruby and Capybara; however,
I code C# all day, but recently made a jump to Java for hobby
Recently I downloaded Live555 server source code from their site. I tried to compile
Recently I tried to write a simple compiler on the linux platform by myself.
I have tried using some browser based IDE's like cloud9 IDE recently. But it
Recently im learning how to write a boot sector, here is the complete code
Recently i developed a code on asp that requires to upload a file up

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.