Check Prime Program - Failing test cases 1, 2 and 4

Hi, please check the following code, it is giving errors in test cases 1, 2 and 4
https://ide.codingblocks.com/s/51827

you have to check for the n%i==0 condition for the whole loop and if you find any n%i==0 for i other than 1 and number itself that means it is not prime and after checking for every number greater 1 and less than n print if its prime by making use of flag variable .

https://ide.codingblocks.com/s/51847 like this.