CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2009
    Posts
    13

    console application help

    Hi everyone! I am new here and I am new in C# (started to learn it his year at Uni). I hope you won't mind to help me with my homework. I got the console application to do. the task says
    "Write a program to output the numbers 1 to 20 inclusive, excluding the numbers 5 and 18". I did it, but it shows all the numbers starting from 1 till 20, and I can't think how to make it right. Please help! Thank you!

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: console application help

    So, we don't usually do homework for people here, but it seems to me that you would simply check for the numbers '5' and '18' and not print them...

  3. #3
    Join Date
    Oct 2009
    Posts
    13

    Re: console application help

    hi thanx for reply. All i need just a hint how to do it as i stuck. the program should output (as i understand it) numbers in a row 1-till 20 excluding 5 and 18.

  4. #4
    Join Date
    Jun 2008
    Posts
    2,477

    Re: console application help

    ok, so...

    Code:
    for ( int i = 1; i < 21; ++i )
    {
        if ( i != 5 && i != 18 )
        {
            Console.WriteLine( i );
        }
    }

  5. #5
    Join Date
    Oct 2009
    Posts
    13

    Re: console application help

    aaaaaaaa!! Thank you!! (grrr! so easy!)
    i study it 1st month as i am 1st year student. Sorry to bother you. I will try to find some other forum for the beginners. Thanx again!

  6. #6
    Join Date
    Jun 2008
    Posts
    2,477

    Re: console application help

    It's ok, you don't have to find another forum. We are glad to help students with their homework, we just prefer not to hand them an answer. Next time, just post some code which shows what you have already tried, tell us what the problem is, and we will help you think through it.

  7. #7
    Join Date
    Oct 2009
    Posts
    13

    Re: console application help

    Thanx mate! I'm really appriciated!! I was thinking since yesterday, and now it is so easy so i think how could I not do it??!!
    Thanks a lot!

  8. #8
    Join Date
    May 2007
    Posts
    1,546

    Re: console application help

    Quote Originally Posted by BigEd781 View Post
    We are glad to help students with their homework, we just prefer not to hand them an answer.
    But you did just hand them the answer As this is the first month of learning how to program, they really should be checking their notes for this kind of stuff. It's far too early to start getting handed the answers online, they might get lazy!
    www.monotorrent.com For all your .NET bittorrent needs

    NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.

  9. #9
    Join Date
    Oct 2009
    Posts
    13

    Re: console application help

    hehe I promise i won't ask for answers anymore and I will work hard

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured