Answer to Question #252697 in C++ for koi

Question #252697

Develop an algorithm in form of a pseudocode to solve the following problem: You are given an array of positive numbers, determine if there are any two integers in the array whose sum is equal to the given value X, and display all pairs of integers in the array that add up to X. Look at the below test case to guide you. (NB: do not write a C++ program but pseudocode) [5 Marks] Array: {7,1,2,8,4,3} Target sum/value (X)= 10 Expected Output: 7 + 3 = 10, 2 + 8 = 10 


1
Expert's answer
2021-10-19T00:50:04-0400

-        Define Target Sum = X

-        Get the integer number array as Num

-        Get the size of Num array as: L = sizeof(Num)/sizeof(Num[0])

-        for (r = 0; r < L ; r++)

{

           for (c = 0; c < L; c++)         

{

           if         Num[r] + Num[c] == X      

then,  Display (Num[r] and Num[c]

}

}



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS