I hope you already know that you can not buy entrance ticket for Machu Picchu at entrance. Though it is very natural to think that ticket can be bought at the opening gate, this is not the case here. If you reach all the way up to the ruins without the tickets, it would ruin your day, because then you have to go back to Aguas Calientes to buy the ticket.
You can buy the tickets at Aguas Calientes. At central Plaza where you see the statue of Pacahcuti, from here you have to walk 10 minutes to reach Machu Picchu Cultural Center. If you reach Aguas Calientes by train, you need not to worry, by then it is already open. Even if you think you reach Aguas Calientes at evening, and thinking of going to ruins early in the morning, still you can get the tickets, since this ticket center opens at 5.15 am (Open from 5.15 am to 7 pm). If you go there early in the morning take the exact change of 122 sole (around $44.00). Usually they don't have the change, and in morning they never have it. So don't forget to take the exact change. And yes, you have to buy it in soles not in dollars.
There is a discount for students. Students have to pay only 50%, but for that you need ISIC card. If you have any other student ID than ISCI card, it will not be accepted. So if you have a ISIC card , must carry it, or if you don't have it, you can get it from ISIC website.
Entrance ticket at Aguas Calientes..
Yes, you can buy it from NIC (Instituto Nacional de Cultura) office at Cusco. If you are living near Plaza de Armas, then it is very easy to get this ticket, since the office is only few blocks from NIC office (at Calle San Bernado).
This ticket is valid for three days. So you can buy it from Cusco, though you may not go to Machu Picchu next day. But don't think that you can get in the ruins three days with this ticket. You can use this ticket to the ruins only once (not actually once, you can get in again on the same day with the same ticket). If you are planning to visit the ruins next morning, you have to buy another ticket and at full price.
Ticket from hotels..
If you just reach hotel at night and planning to leave for Machu Picchu early in the Morning, you can try to have it form your hotel. If you can get it from the hotel, you must have it, though they may charge some extra money (usually not much) for tickets. If you don't take it from the hotel, and you have no time to buy it from Cusco, and you are in a day trip to Machu Picchu, then you can still buy it from Aguas Calientes. But then you have to stop at Machu Picchu Pueblo station at Aguas Calientes rather than going directly to Puente Ruinas station at the foot of Machu Picchu. You will lose valuable time there and also have to pay extra $1.50 bus fare ( from Aguas Calientes it is $4.50, but from Puente Ruinas, $3.00). So my final advice for those who are coming MAchu PIcchu in a day trip, get the entrance ticket at Cusco, either form NIC office or from your hotel.