Thread: My idea.

  1. #31
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by Adak View Post
    C'mon, you know this can't be right!

    Code:
        do {
            printf("Please provide a temperature less that 200C.\n");  //Asks for a temperature for the higher temperature,
            scanf("%d", &high);
            printf("\n");
        } while (high > UPPER);                                        //and checks to make sure it is less than 200C.
    Think through your loops, a bit more. UPPER is 200, and you want high to be something LESS than that.
    Think through your loops a bit more. If high is more than the upper limit, I think you should repeat. > and < is all about the placement of the arguments.

  2. #32
    Registered User
    Join Date
    Sep 2012
    Posts
    1
    Hi I'm new to programming, and I found MSDN's Channel 9 website to be a great place to start for video tutorials (MSDN = MicroSoft Developer's Network)

    Channel 9 Content for Beginners | Channel 9
    --A set of beginner friendly tutorials on different languages, one of which is C# (which isn't C of course, but still down your alley)
    Series | Browse | Channel 9
    --Same website, but this link is the master list for all of their series' so that you can see if there's any tutorial series' for C or other languages you may be interested in

    These tutorials are kick-butt because they are available for free download, no catch, no "go pro" account necessary...just download it in your choice of codec and start watching . Further, they offer the full set of accompanying source code for download (at least for the C# series; I can't speak for the other series) And if you want an extra copy of just the audio-only to listen to on your iPod/MP3 Player/CD/etc. they have that for download too.

    As a beginner I find it really helpful to have video walkthroughs. Text based learning can really cover a lot of concepts quickly, which is great, but its nice to have some learning resources that slow things down a bit as well and guide you through step by step.

    iTunesU is another resource to look up learning materials.

    Sorry I don't have anything to reply regarding your code...I'm still too new to programming for that
    Last edited by AGENT_P6; 09-15-2012 at 09:38 AM. Reason: typo

  3. #33
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by whiteflags View Post
    Think through your loops a bit more. If high is more than the upper limit, I think you should repeat. > and < is all about the placement of the arguments.
    Yes, it was meant to be a satire about using a while loop for user's who can't read.

    After I wrote it, I realized it might not be seen as such, which is why it was removed.

  4. #34
    Registered User
    Join Date
    Sep 2012
    Posts
    25
    Quote Originally Posted by whiteflags View Post
    Think through your loops a bit more. If high is more than the upper limit, I think you should repeat. > and < is all about the placement of the arguments.
    That was a loop to ask them to re-enter a temperature if high > the upper limit. I see nothing wrong with that bit of code.

    Want to explain what is wrong with it?

  5. #35
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    I see nothing wrong with it either. I was contradicting the person I quoted.

    Quote Originally Posted by Adak View Post
    Yes, it was meant to be a satire about using a while loop for user's who can't read.

    After I wrote it, I realized it might not be seen as such, which is why it was removed.
    As you see from the above, it seems to be an attempt at humor on the internet that went horribly wrong.

  6. #36
    Registered User
    Join Date
    Sep 2012
    Posts
    25
    Gotcha. I thought i did a pretty decent job, and actually preferred it to the "solution." Sure I could enable it to input bigger numbers I guess. But overall I was pretty happy with it.

  7. #37
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    Code:
    #define UPPER 200
    ...
    do {
        printf("Please provide a temperature less that 200C.\n");  //Asks for a temperature for the higher temperature,
        scanf("%d", &high);
        printf("\n");
    } while (high > UPPER);                                        //and checks to make sure it is less than 200C.
    If you use a macro for constant values you should use it everywhere in your code. Otherwise it's rather useless.

    Code:
    do {
        printf("Please provide a temperature less than %dC.\n", UPPER); 
        scanf("%d", &high);
        printf("\n");
    } while (high > UPPER);
    And it's "Fahrenheit" :-)

    Bye, Andreas

  8. #38
    Registered User
    Join Date
    Sep 2012
    Posts
    25
    Quote Originally Posted by AndiPersti View Post
    Code:
    #define UPPER 200
    ...
    do {
        printf("Please provide a temperature less that 200C.\n");  //Asks for a temperature for the higher temperature,
        scanf("%d", &high);
        printf("\n");
    } while (high > UPPER);                                        //and checks to make sure it is less than 200C.
    If you use a macro for constant values you should use it everywhere in your code. Otherwise it's rather useless.

    Code:
    do {
        printf("Please provide a temperature less than %dC.\n", UPPER); 
        scanf("%d", &high);
        printf("\n");
    } while (high > UPPER);
    And it's "Fahrenheit" :-)

    Bye, Andreas

    Could you explain how I should use a macro everywhere? And point out which term is considered a Macro?
    Also thanks for the spelling. I can never spell Fahrenheit. And I couldn't figure out spell check in my coder.

  9. #39
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by Zach Sisk View Post
    Could you explain how I should use a macro everywhere? And point out which term is considered a Macro?
    Code:
    printf("Please provide a temperature less that 200C.\n");
    vs
    Code:
    printf("Please provide a temperature less than %dC.\n", UPPER);
    the UPPER is the macro which is expanded to the literal value you set it to , before compilation.

  10. #40
    Registered User
    Join Date
    Sep 2012
    Posts
    25
    Quote Originally Posted by manasij7479 View Post
    Code:
    printf("Please provide a temperature less that 200C.\n");
    vs
    Code:
    printf("Please provide a temperature less than %dC.\n", UPPER);
    the UPPER is the macro which is expanded to the literal value you set it to , before compilation.
    Gotcha, didn't think about that. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Any idea?
    By Moony in forum C Programming
    Replies: 9
    Last Post: 07-05-2006, 02:47 AM
  2. what's the big idea here?
    By misplaced in forum C++ Programming
    Replies: 7
    Last Post: 10-05-2004, 11:12 AM
  3. No idea at all...
    By WeZ in forum C++ Programming
    Replies: 5
    Last Post: 03-04-2004, 12:02 PM
  4. Good idea, bad idea.
    By sean in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 06-15-2002, 12:26 PM
  5. new idea....need help!
    By lonelyplanetwanderer in forum C Programming
    Replies: 5
    Last Post: 04-01-2002, 08:44 AM

Tags for this Thread