Because C/C++ code is a compiled language, it's not aware of any variables you didn't define yourself at compile-time. In this case we need to use a library call to get shell variables, and even then we can't get all shell variables, only ones your shell has exported.
In shell:
export range=100
In program:
#include <stdlib.h>
int main(int argc, char *argv[])
{
const char *range=getenv("range");
if(range == NULL)
{
cout << "Range not available\n";
}
else
{
cout << "Range is " << range << "\n";
}
return(0);
}