Ask Question
27 August, 21:22

Part of the following pseudocode is incompatible with the Java, Python, C, and C+ + language Identify the problem. How would you fix the problem if you were to translate theis pseudocode into one of the aforementioned languages?. Module checkEquality (Integer num1, Integer num2)

If num1 = num2 Then

Display * The values are equal.*

Else

Display * The values are Not equal.*

End if

End Module

+4
Answers (1)
  1. 27 August, 23:56
    0
    The main problem is the incorrect use of assignment operator, the correct way to check if two number are equal is

    num1==num2

    Explanation:

    Here we have a created a simple function which takes two input arguments num1 and num2. In the body of the function we have used if condition to find out whether the two number are equal or not. If condition is true then print that values are equal. If condition is false then print that values are not equal. In the driver code, we have called the function two times with different values of num1 and num2 to check if it is working correctly.

    The implementation logic is same in all these programming languages, the only difference the syntax.

    Python Code:

    def checkEquality (num1, num2):

    if num1 = = num2:

    print ("The values are equal.")

    else:

    print ("The values are not equal.")

    Driver Code:

    checkEquality (2,5)

    checkEquality (3,3)

    Output:

    The values are not equal.

    The values are equal.

    C+ + Code:

    void checkEquality (int num1, int num2) {

    if (num1 = = num2)

    cout<<"The values are equal."<
    else

    cout<<"The values are not equal."<
    }

    Driver Code:

    #include

    using namespace std;

    void checkEquality (int num1, int num2);

    int main ()

    {

    checkEquality (2,5);

    checkEquality (3,3);

    return 0;

    }

    Output:

    The values are not equal.

    The values are equal.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Part of the following pseudocode is incompatible with the Java, Python, C, and C+ + language Identify the problem. How would you fix the ...” in 📘 Engineering if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers