return code of a process

two programs A and B writting in c++
I am using A to B and I want to know the return code of B.
in B
------------------------
int main()
{
return 11;
}
------------------------

in A
------------------------
int main()
{
system(A);
}
------------------------

Is it the right way to call B if I want the return code? If it is not, How?
Thanks a ton

I have deleted my message. After browsing some other posts on the site, this is a homework question. I thought that this was homework, but since you had done some work, I'd point you in the right direction. But it turns out that what you've posted is part of the question, so that's a no go.

And please do not post any more homework questions. Here are the rules. Please read them.

This is also a warning. Any more homework questions will result in a ban.