Sample Code:
Contact c = [ SELECT Account.AccountNumber, LastName FROM Contact WHERE Id = ‘003U000001cdHIf’];
c.LastName = ‘Testing’;
c.Account.AccountNumber = ‘222’;
update c;
update c.Account;
Cheers!!!