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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:46:41+00:00 2026-06-12T19:46:41+00:00

Given a program of : int main() { short myVariableName1; // stores from -32768

  • 0

Given a program of :

int main()
{

    short myVariableName1;  // stores from -32768 to +32767
    short int myVariableName2;  // stores from -32768 to +32767
    signed short myVariableName3;  // stores from -32768 to +32767
    signed short int myVariableName4;  // stores from -32768 to +32767
    unsigned short myVariableName5;  // stores from 0 to +65535
    unsigned short int myVariableName6;  // stores from 0 to +65535

    int myVariableName7;  // stores from -32768 to +32767
    signed int myVariableName8;  // stores from -32768 to +32767
    unsigned int myVariableName9;  // stores from 0 to +65535

    long     myVariableName10;  // stores from -2147483648 to +2147483647
    long     int myVariableName11;  // stores from -2147483648 to +2147483647
    signed   long myVariableName12;  // stores from -2147483648 to +2147483647
    signed   long int myVariableName13;  // stores from -2147483648 to +2147483647
    unsigned long myVariableName14;  // stores from 0 to +4294967295
    unsigned long int myVariableName15;  // stores from 0 to +4294967295
    cout << "Hello World!" << endl;
    cout << myVariableName1 << endl;
    cout << myVariableName2 << endl;
    cout << myVariableName3 << endl;
    cout << myVariableName4 << endl;
    cout << myVariableName5 << endl;
    cout << myVariableName6 << endl;
    cout << myVariableName7 << endl;
    cout << myVariableName8 << endl;
    cout << myVariableName9 << endl;
    cout << myVariableName10 << endl;
    cout << myVariableName11 << endl;
    cout << myVariableName12 << endl;
    cout << myVariableName13 << endl;
    cout << myVariableName14 << endl;
    cout << myVariableName15 << endl;
    cin.get();

    return 0;
}

Printing out the unassigned variables will print whatever was stored in that memory location previously. What I’ve noticed is that across multiple consecutive executions the printed values are not changing – which tells me that the locations in memory are the same each time they execute.

I’m just curious as to how this is determined, why this is so.

  • 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-12T19:46:42+00:00Added an answer on June 12, 2026 at 7:46 pm

    Those variables live on the stack. The execution of your program looks to be deterministic, so every time you run it the same things happen. It’s not choosing the same address necessarily (many runtimes these days make use of Address Space Randomization techniques to ensure that the stack addresses are not the same between runs), but the relative addresses on the stack contain the same data every time.

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

Sidebar

Related Questions

In the given program: int main() { char *p = \0777; printf(%d %d %d\n,p[0],p[1],p[2]);
On compiling given program in GCC Compiler : int main() { int a=2,b=3; (a>1)?b=10:b=50;
Given below is program for encrypting a string. I had taken this code from
I am writing a simple program to filter out stock quotes from a given
I have this program execute with the values 10,20,30 given at command line. int
Consider this program: #include <stdio.h> int main() { printf(%s\n, __FILE__); return 0; } Depending
I want to write a program that will take substrings from a given string.
This program: #include <iostream> #include <cstdlib> #include <string> int main(int argc, const char *argv[])
Consider the two following programs: program one int main() { printf( hello\n ); }
Below is the program I wrote to find sum of a subarray from given

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.