linux how to check version of package

C++
$ apt list pkg-name
//show all possible versions on repository
$ apt list pkg-name -a
Source

Also in C++: