Yes, you can buy a house earning 40k a year. If you can manage to keep your debt-to-income ratio at 40% or less then you will be qualified for a mortgage loan.