I can not see your problem of the code. Why isn't 127 a prime?
My Note about the difference between const ref and non-const ref
(1)A non-const reference may be attached only to an object of the same type...
Thank you, DaWei! You've made it exceptionally clear!
What is the value of "val" after for's first loop?
for (int val = 1; val <= 10; ++val)
cout << val <<endl; //I...
Separate names with a comma.