Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignments From 38 To 46 - Assignment 2 #3

Open
PhilopaterHany opened this issue Aug 30, 2023 · 0 comments
Open

Assignments From 38 To 46 - Assignment 2 #3

PhilopaterHany opened this issue Aug 30, 2023 · 0 comments

Comments

@PhilopaterHany
Copy link

PhilopaterHany commented Aug 30, 2023

Your Solution works well but is not dynamic enough.

For example, if we change the number of elements in the nums array, everything will vary and get different results. I mean that the 70 won't be on index 3 all the time.

Keep in mind that, if the first number isn't bigger than the check number, so check on the second and third numbers, and so on.

I know that Elzero didn't ask for all of this, but consider it a challenge to improve your way of thinking, why not? 😄

I figured out the dynamic solution, but I want you to try and solve it on your own.
Maybe I can send the solution after you give up. 😂

Of course, the code would be better if we had used functions, but we haven't reached functions lessons yet.

Here are some test cases to ensure that your code is dynamic:

#include <iostream>
using namespace std;

int main()
{
    // Please uncomment the first 2 lines in a test case of your choice and then run the code (as in test case 4).
    // Make sure that only 1 test case is uncommented.

    // === Test Case 1 ===
    // int check = 14;
    // int nums[]{21, 10, 6, 79, 100};
    // Output:
    // "{21} + {79} = 100"

    // === Test Case 2 ===
    // int check = 25;
    // int nums[]{15, 35, 20, 70, 100};
    // Output:
    // "{35} + {70} = 105"

    // === Test Case 3 ===
    // int check = 32;
    // int nums[]{20, 25, 35, 75, 100};
    // Output:
    // "{35} + {75} = 110"

    // === Test Case 4 ===
    int check = 10;
    int nums[]{20, 25, 35, 75, 100};
    // Output:
    // "{20} + {75} = "95"
    // "{25} + {75} = 100"
    // "{35} + {75} = 110"

    // === Test Case 5 ===
    // int check = 20;
    // int nums[]{25, 30, 15, 60, 100};
    // Output:
    // "{25} + {60} = "85"
    // "{30} + {60} = "90"

    // === Test Case 6 ===
    // int check = 16;
    // int nums[]{20, 12, 35, 55, 100};
    // Output:
    // "{20} + {55} = "75"
    // "{35} + {55} = "90"

    // === Test Case 7 ===
    // int check = 30;
    // int nums[]{20, 32, 35, 90, 100};
    // Output:
    // "{32} + {90} = "122"
    // "{35} + {90} = "125"

    // === Test Case 8 ===
    // int check = 50;
    // int nums[]{20, 32, 35, 90, 100};
    // Output:
    // "Sorry, The first 3 numbers are smaller than or equal to 50"

    // Write Your Condition Here

    return 0;
}

Think dynamically, brother.
Contact me if need be.
Good Luck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant