Exchanges allow users to buy, sell, and exchange cryptocurrencies. Just like we have stock and forex exchanges for buying and selling shares and foreign currencies, similarly we have exchanges for cryptocurrencies.
In general, crypto exchanges allow buying and selling of cryptocurrencies using fiat currencies or stablecoins or other cryptocurrencies. For example, you can buy bitcoin using USD and sell bitcoin for USD. You can also convert bitcoin into ether and vice versa, using a crypto exchange.
Crypto exchanges are of two kinds — centralized and decentralized.
Centralized exchanges are basically order book based platforms that manage keys for the users, and make blockchain transactions on behalf of the user. All trades go through a central server. They allow exchange of crypto with fiat and accept fiat payments and withdrawals. Centralized exchanges generally provide custody services to users for their purchased tokens. This means the users don’t have control on their wallets when transacting using centralized exchanges.
Decentralized exchanges are implemented using smart contracts (or logic on a blockchain) and allow users to directly make trades on the blockchain. They are more secure and allow full control of keys to the users, but they only work within the blockchain network and do not allow exchange with fiat currencies. The smart contract logic acts as automated market maker and matches the demand-supply for making token swaps. The market making and swapping of tokens is based on liquidity pools.