Compare three different people:
- one person gets work from some repository of work items or a project plan or the like and quietly finishes it without much announcements or "visibility"
- one person gets work in the same way, but goes to the boss and says "I am planning to do this like this, am I right?" or "I've started doing this but I need to check about X, tell me how to do that please."
- one person gets work in the same way, but as each thing is completed, tells the boss it is completed.
Different companies will value those people differently, and for different reasons. For example, in many companies the work items you pick up are not completely specced, and if you just do the work on your own you may make some choices the boss doesn't like. By asking the boss first you ensure the results you produce align well with the boss' expectations. In others, the boss doesn't regularly check the status of the work items or the project plan and literally doesn't know what you're getting done unless you personally report it.
So to solve your problem you need, for at least a moment, to assume your boss is a mature and sensible adult, not a spoiled little child who randomly promotes people "for making me feel good and smart."
Take a moment to categorize the questions people ask the boss. Is it "I need more details on what you want?" or is it the sort of thing you should ask on StackOverflow (or the equivalent for your work.) If it's the former, you should start doing it. Get the details you need before you do the work. As a side effect, the boss will always know what you're up to. If it's the second one, then don't start doing it, but think about this: how does your boss know what you have finished? You could develop a habit of letting the boss know what you're starting and finishing.
There could possibly be other sensible, mature, decent explanations for why the people who bother the boss with questions are rewarded. If you can be objective and observe what they ask and what happens, you may come to realize that this asking is not meaningless ego-boosting for the boss, but is in fact a workaround for flaws in the process of your team. I want you to really look for that explanation, and look hard. It will be good for you to understand what your boss does with your work and what your boss needs to know about your work.
But it may be that in fact there is no good reason. Your boss is just lazy and selfish and would rather do the old work (such as solving programming problems) than the new work (managing people and projects, probably) and feels happy with the people who make that possible by coming with questions all the time. Ask yourself if there is something you can do that will give the boss the same good feeling, or if what you really need is a different boss. But don't start considering those things until you truly understand the phenomenon you have started to observe. In my experience many people misunderstand the things they see in the office and assume things are motivated by childishness and selfishness, not by the flawed workings of a process you don't fully understand.