Can anyone explain difference between declare and typeset with real life examples .
declare are exactly the same. The only difference is that
typeset is considered obsolete.
typeset: typeset [-aAfFgilrtux] [-p] name[=value] ... Set variable values and attributes. Obsolete. See `help declare'.
The man page even lists them in the same breath:
declare [-aAfFgilrtux] [-p] [name[=value] ...] typeset [-aAfFgilrtux] [-p] [name[=value] ...] Declare variables and/or give them attributes.
typeset is portable to some other shells, for example,
ksh93. If you are aiming for cross-shell portability, use
typeset (and make sure that the way you are calling it is portable). If you don't care about such portability, use