I am new to programming using c++ and I want to make a program that prints the first N prime nos.when I debug it doesnt give me the desired output for example I input 5 it gives me :2 3 4 5 6 whats my mistake?
Notice bool on line 14. It makes so that you are defining a new variable that is local to that if statement and is not the same variable as you defined on line 9 so that's why it remains unchanged.
Perhaps you should read some introductory material, for example the http://www.cplusplus.com/doc/tutorial/
in order to learn at least some of the basics first.