If I give you a number and asked you to find whether it is even or odd. You can easily answer the question as we know how to check whether the number is even or odd. There are several techniques for that : * Method 1 : If the last digit of the given number is [0 or 2 or 4 or 6 or 8], then it is an even number, otherwise it is an odd number. * Method 2 : If the given number is exactly divisible by 2, then it is even number, otherwise it is an odd number. We can check whether the number is exactly divisible by another number by using the "%" (remainder after division) operator. If the remainder is 0, then the first number is exactly divisible by the second number. * Method 3 : The simplest way is, find the bitwise AND of the given number with 1. If the result is 1, then the given number is odd, if the result is 0 it is even. Let me explain, how this works, Ex : Given number 6 Here we are considering only 8 bits as the numbers are small. Internally an integer value is store
Comments are used in the program just to give the information to the person who reads your code, not the compiler. The compiler don't executes the comments, it just ignores them. There are two types of comments depending on the number of lines you want to write. If your comment is single line : Use "//" in the beginning of the line. If your comment is multiple lines : Use "/*" in the beginning of the comment, and "*/" in the end of the comment. NEXT