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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:52:00+00:00 2026-05-13T22:52:00+00:00

There is a question in my programming languages textbook that is as follows: Write

  • 0

There is a question in my programming languages textbook that is as follows:

Write a C function that includes the
following sequence of statements:

x = 21;
int x;
x = 42;

Run the program and explain the
results. Rewrite the same code in C++
and Java and compare the results.

I have written code, and played with it in all three languages but I can not even get it to compile. This includes declaring x above the three lines as well as in the calling function (as this question is obviously attempting to illustrate scoping issues)

I’d like to explain the results and do the comparisons on my own, as it is an assignment question but I was wondering if anyone had any insight as to how to get this code to compile?

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-13T22:52:00+00:00Added an answer on May 13, 2026 at 10:52 pm

    Note the following requires C99:

    int x;
    
    void foo()
    {
        x = 21;
        int x;
        x = 42;
    }
    

    Since this is homework, you’ll need to provide your own explanation.

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

Sidebar

Related Questions

Update: This question is a duplicate of Are there any programming languages targeting PHP,
This should be very simple question. There are many programming languages out there, compiled
Another newbie (Common) LISP question: Basically in most programming languages there's a mean for
I was wondering if there are functions in any programming languages that allow you
Simple question: Is there a class or interface that encapulates the getting of a
There is a question here in stackoverflow with the same title but that is
Are there any extensible interpreted programming languages written in standard, platform-independent C or C++?
Edit: I'm looking for solution for this question now also with other programming languages.
Is there a programming language that is testable by design or at least exhibit
This is a basic Question for all programming languages, But I am much familiar

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.