First of all the odds that you startle a bear in this way are quite low. There is a good chance that it would have heard or smelled you before you get that close.
That said, if you encounter a bear in the wilderness, your reaction depends on how the bear is acting. In most cases, the bear will be defensive. In this case you should stay calm, talk calmly to the bear, make yourself look big and slowly move away facing the bear, always facing it.
However, if the bear is aggressive, or is approaching you, your reaction should be different. A good guide of what to do in these situations can be found at parks canada's website.