This C++ program will help you to check whether a number is prime or not. The logic of this program is very simple. Loop from 2 to the half of that number. For example, if you have to check whether 11 is a prime number or not, you’ll loop from 2 to 5 (not 5.5 :P) check whether 11 is divisible by any of the number 2,3,4 or 5. If found, we set flag to zero indicating that the number is not prime. After the loop we print the result according to flag is 0 or 1.Continue reading

This is a very simple c++ program that helps you to check whether an entered string is a palindrome or not. The procedure is simple. We have an array str. We read it from the user. Now we loop upto the middle of the string (len/2) and checks whether 1st character matches len-1th character, 2nd matches len-2th character and so on.. If the string is a palindrome and the break inside the for loop is not executed then the value of i will be len/2 at the end. So we print the result according to i is len/2 or not.Continue reading