Search This Blog

If you have any problem or question please write in the comments. We will try to solve and send you the solution. Not just that we will also post your problems solution on our blog.

Tuesday, 5 July 2011

Write a program that print all even numbers from 0 to a given range


import java.util.*;
class even
{
public static void main (String arg[])
{
int a;
System.out.print ("\n\t Enter the number = ");
a=in.nextInt();

while (a>0)
{
if (a%2==0)
System.out.print ("\n\t "+a);
--a;
}

}
}

Note:
         In this program, body of the loop will be executed till a is greater than 0. As you have
noticed a conditional statement in the body of the loop, this is the actual code in our program
which is checking that either the number is even or odd.

10 comments:

  1. Wow! At last I got a weblog from where I can genuinely get useful information regarding my
    study and knowledge.
    Also see my site: His Response

    ReplyDelete
  2. You really make it seem really easy along with your presentation however
    I in finding this matter to be really something that I feel I would never understand.
    It kind of feels too complex and very large for me.
    I'm having a look ahead on your next post, I'll try to get the hang of it!
    My site :: this hyperlink

    ReplyDelete
  3. Fantastic blog you have here but I was wanting to know if you knew of any message boards that
    cover the same topics discussed here? I'd really like to be a part of community where I can get feed-back from other knowledgeable people that share the same interest. If you have any suggestions, please let me know. Thank you!
    Here is my website : found it

    ReplyDelete
  4. I read this post completely concerning the difference of latest and preceding technologies, it's amazing article.
    my web site > this hyperlink

    ReplyDelete
  5. Fantastic goods from you, man. I have understand your
    stuff previous to and you're just too excellent. I actually like what you've acquired
    here, really like what you're saying and the way in which you say it. You make it entertaining and you still care for to keep it sensible. I can't wait to read far more from you.
    This is actually a tremendous website.
    Also see my webpage: real love spells that work

    ReplyDelete
  6. What's up colleagues, its enormous post about tutoringand fully defined, keep it up all the time.
    Also see my site - I found it

    ReplyDelete
  7. Touche. Outstanding arguments. Keep up the amazing work.
    Also visit my website :: look what I found

    ReplyDelete
  8. It is perfect time to make some plans for the future and it is time to be happy.
    I've read this post and if I could I desire to suggest you few interesting things or tips. Perhaps you can write next articles referring to this article. I want to read even more things about it!
    My site > description

    ReplyDelete
  9. It is not my first time to visit this site, i am
    browsing this site dailly and take fastidious facts from here all the
    time.
    Also visit my web-site :: visit

    ReplyDelete
  10. What's up, all is going nicely here and ofcourse every one is sharing facts, that's in fact good, keep up writing.
    Feel free to surf my blog post - directory

    ReplyDelete