Write a function in c that includes the following sequence of statements [Wont Compile]
- by Cody
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