When faced with the task of writing-- whether it be a term paper, short story, article, etc.--many of my friends worry that they don't know what to write. In contrast, I rarely ever have that problem. I used to think that it was because maybe I was more creative, or flexible with my ideas... then I learned to stop being so self centered. That's when I realized that, over the past few years, I've developed a lot of helpful idea-generating practices, and that maybe instead of internally talking about how superior I am, I could just share them with the world (or at least the Internet).
1. Record Your Thoughts
Whether it be a few quick reminders stored in "notes" on your cell phone, a journal you write in expansively whenever you're feeling inspired, or anywhere in between, one of the best things you can do for yourself is record important or interesting thoughts as you have them. It's rediculous to expect yourself to always have great ideas ready at the drop of a hat, and it's also just about impossible for the average person to recall every useful thought they've ever had. Jotting down your ideas when inspiration strikes is a great way to remember them, and keeping them all together creates what I can only describe as a toy box of ideas-- plus, even if you don't use the ideas you already had, they may help you to come up with new ones.
2. Study
As strange as it sounds, some of my best ideas for writing have come from leafing through old notes from history class or Economics. This is not to say you'll end up writing about those topics, but someone like Ghandi or Ponzi can make for a great character, or just get you thinking in a different way. If you're not in school, or you just don't take notes, randomly browsing the Internet can have a similar effect.
Side note: you can also use writing prompts, but personally I do not choose to.
3. Research
This is not quite the same as "Study," because for research, you need a topic. If you already know generally what you want or need to write about, then looking up more specific facts can be great for generating ideas-- even if you have no idea what, specifically, you are looking for. HOWEVER, I cannot stress enough that you should try to find facts that are interesting to you. Nothing is less inspiring than disinterest.
4. Write What You Want
A lot of the time, not knowing what to write about can just come from a disinterest in the topic, a feeling of being overwhelmed, or just being distracted by other things. In those scenarios, it can really help to just write about what you're actually thinking of, and then try to progress from that, to your real task. Sometimes, you may even decide to keep the writing you begin with as a hook for readers, and similarly, relating the topic to what you're really interested in at that time can help you gain interest, too. If you're overwhelmed by a million, amazing possibilities, this can help you narrow it down to the one you are most interested in, or know the most about.
5. WRITE
This is the golden rule. If you have no ideas, and you're stressed out just staring at the paper, LITERALLY JUST WRITE ANYTHING and DO NOT STOP. You have to get your brain into writing mode. Yes, whatever you start out with will almost certainly need to be trashed, but that's not important. Never worry about writing well all of the time. No one ever does; that's what revision is for. In the words of Shia LaBeouf, "JUST DO IT!" (I am now realizing I may have already used this quote in a previous article, but oh well, it's actually pretty good advice).
All of that said, yes, there will still be times where, even if you can get yourself writing, none of it is any good. There will also be times when you do have ideas, but they are just really, really bad (regardless of what anyone says, there are definetly bad ideas and bad questions). Those times are certainly annoying, but they are also great learning tools as examples of "what not to do".
Additionally, you may also have a great idea that you can't properly put into words, or that no one else seems to appreciate. Those times are just plain frustrating... but at least you wrote it, right?
In the end, there are so many things to worry about when writing a piece, and obviously the topic is one of the absolute most important parts... But it's also preliminary. My biggest piece of advice is probably just: don't waste too much time trying to come up with ideas. Just get writing, and (nine times out of ten) your piece will find its own topic. Don't give up before you've even started