if/else statement
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: if/else statement

  1. #1
    Join Date
    Sep 2017
    Location
    NY
    Posts
    1

    if/else statement

    Name:  2017-09-22.jpg
Views: 93
Size:  16.9 KBName:  2017-09-22 (1).jpg
Views: 73
Size:  28.1 KB

    I'm a student and I have no clue what's wrong with my statement, it's not a compilation error because it just asks for the statement. The errors I get are that salesTrend does not have the proper value assigned and that I did not modify salesTrend. The test case table returns everything correctly except when soldYesterday and soldToday are equal. Any help is appreciated, sorry if this seems like a silly mistake.

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    5,881

    Re: if/else statement

    Sorry, but I can't read the code on the images - nor the exercise requirement. Please copy and paste the code into a post using code tags so that the code is readable and also the requirement.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2017 (15.5.1)

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    19,015

    Re: if/else statement

    Quote Originally Posted by se7enteenblack View Post
    I'm a student and I have no clue what's wrong with my statement, it's not a compilation error because it just asks for the statement. The errors I get are that salesTrend does not have the proper value assigned and that I did not modify salesTrend. The test case table returns everything correctly except when soldYesterday and soldToday are equal. Any help is appreciated, sorry if this seems like a silly mistake.
    I agree with 2kaud.
    And you might want to read the Announcement: Before you post.... section.
    Victor Nijegorodov

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,507

    Re: if/else statement

    Read the assignment and read your code. You've assigned three possible values to salesTrend. The assignment only calls for two.

  5. #5
    Join Date
    Feb 2017
    Posts
    187

    Re: if/else statement

    Quote Originally Posted by se7enteenblack View Post
    except when soldYesterday and soldToday are equal
    Note that the logical negation of (a<b) is (a>=b) so,

    Code:
    if (a<b) {
        // the (a<b) case
    } else {
        // the (a>=b) case
    }
    These are the two cases the exercise asks you to distinguish (and not to also separate out the equality (a==b) case).

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)