Share
Explore BrainMass

Programming Exercise

Write a function that includes the following sequence of statements:

x = 21;
int x;
x = 42;

I need to run the program in C, C++, and JAVA. If I can get started in one of the languages I will be able to complete the rest. Thanks.

Solution Preview

Following is the method in Java:

public int myMethod(int x)
{
x = 21;
x = 42;
return x;
}

It will ...

$2.19