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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:11:57+00:00 2026-05-30T20:11:57+00:00

Following is the program that raised the mentioned doubt for me. #include <stdio.h> int

  • 0

Following is the program that raised the mentioned doubt for me.

#include <stdio.h>
int main() { 
    int g = 300000*300000/300000;
    printf("%d",g);
    return 0;
}

When the * is evaluated the result would be 90000000000. Then is divided by 300000.
I expected the first expression result to be stored somewhere then divided by 300000. So output would be 300000.

But it is giving me -647.
Does this mean it is evaluated as :

g = 300000*300000;
g = g / 300000;
  • 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-30T20:11:58+00:00Added an answer on May 30, 2026 at 8:11 pm

    Regardless of where it’s stored, it’s still of type int. Assuming int is 32-bits on your machine, you’re getting integer overflow with 300000*300000.

    300000*300000 -> 90000000000 -> -194313216  (integer overflow)
    -194313216 / 300000 -> -647
    

    Basically, temporaries (or intermediates) don’t magically allow you to get around overflow.


    *Note that signed integer overflow is technically undefined behavior. But in this case it happens to wrap-around the way you’d expect.

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

Sidebar

Related Questions

Consider the following simple C program that read a file into a buffer and
the following is a line from a python program that calls the demo.exe file.
I have a program that looks like the following: double[4][4] startMatrix; double[4][4] inverseMatrix; initialize(startMatrix)
I have a program that makes use of the following method to get a
I have a python program that reads floating point values using the following regular
I am trying to write a C++ program that takes the following inputs from
When running a Python program that reads from stdin, I get the following error:
I need to create an installer program that will do install the following: ASP.Net
With win32api, I want that the following program creates two process and creates a
Assume that we have the following code: class Program { static volatile bool flag1;

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.