So you expect us to provide answers to your test, for free?
Guess again. This isn't the first time you pasted buggy/bad/incomplete code, without code tags, and expected us to give you answers to "what does this do?"
If you have learned the subject of the class, then you should understand the code.
If you have failed to learn, then by definition you should not pass.
... and please learn how to use code tags to format code
[code]
the formatted code goes here
[/code]
1 2 3 4 5 6 7 8 9 10 11
void fun();
void main() {
int x = 1;
fun();
printf("%d", x);
}
void fun() {
int x = 2;
printf("%d", x);
}
what does this print?
As it is invalid code and doesn't (shouldn't) compile then there is no compiled code to run - so nothing prints (except perhaps an error re no such program).
Rather than "invalid", that is "an incomplete program". A part of program.
A human reader should know what the "printf()" is; a compiler has to be told.
Well, the 'void' in 'void main' is not valid by both C and C++ standards.
Looks C, rather than C++. Probably ancient fragment of code.
I tried the OP's code as given, as C code, in both VS 2022 and TDM-GCC (Dev-C++). 2022 spit up compile-time errors, TDM-GCC compiled the hot mess with several warnings.
The OP's compiler could be one that accepts non-standard usage.