I'd recommend adding 2 functions. getLength() and getWidth() each of which returns an integer. That way you don't need to use any globals.
Code:
int getLength()
{
int A;
cout << "Input The Length: ";
cin >> A;
cout << endl;
return A;
}
Then in the calling functions you can use int A = getLength();. And do the same for getWidth().
[edit] Now that I think about it, 2 functions would be redundant since you can use 1 and name it something like getSide.
Example...
Code:
void mainA()
{
int A = getLength();
int B = getWidth();
for (int a = 0; a < A; a++){
for (int b = 0; b < B; b++){
cout<<"O";
}
cout<<"\n";
}
}
Additionally, clean up your int main(). I shudder whenever I see a recursion to main(). Here's an example that I cleaned up for you...
Code:
int main()
{
int A = 0;
do {
cout<<"Enter 1 for the object to have area,\nEnter 2 for the object not to have area: ";
cin>> A;
cout<<"\n";
if (A == 1)
mainA();
else if (A == 2)
mainB();
} while ( A != 1 && A != 2 );
end(); // remove this function call from mainA and mainB
return 0;
}