If "makanan" is food and "makan" is to eat, then "an" is an affix... so pertanya is to ask?
No, "pertanyaan" is constructed from "per+tanya+an", which translates into "question"
The affix (or in this case confix) "per + verb + an" has the function of creating the result of the verb
Tanya => ask
Pertanyaan => question
If you want to see Indonesian affix in quick glance you could see http://indodic.com/affixeng.html