How to print id of user whose profile I visit rather than id of  logged in user?
The function menu_get_object() allows you to get a user/node/.. object based of the current request URL.

To get the account object, you can do this:

if ($account = menu_get_object('user')) {
  print $account-&gt;uid;
}