Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HALIX PROGRAMMING C++ 1. Write Halix machine code to read and add 5 values. Test cases: 1 2 3 4 5 ==>15 -1 -2 -3

HALIX PROGRAMMING C++

1. Write Halix machine code to read and add 5 values.

Test cases: 1 2 3 4 5 ==>15 -1 -2 -3 -4 23 ==> 13 0 0 0 0 0 ==> 0

2. Write Halix machine code to read a value: Double it if the nu halve it when it's odd.

Test cases: 14 ==> 28 0 ==>0 25==>12 -2==>-4 -7==>-3

3. Write a program that reads ans echoes (display what was just values that are terminated by the value 777.

Pseudo Code: int val;

cin >> val;

while (val != 777)

{

cout > val;

cin >> val;

} cout << 4444;

Test cases: 1 2 777 ==> 1 2 4444 777 => 4444 25 777 ==> 25 4444 -2 7 9 4 3 84 777 ==> -2 7 9 4 3 84 4444

4. Write a program that reads input values terminated by the value 9999, and computes the product of the negative values, and the sum of the positive value.

Pseudo-code: int val, negProd=1, posSum=0;

cin >> val;

while (val != 9999)

{

if (val < 0)

negProd *= val;

else

posSum += val;

cin >> val;

}

cout << posSum << negProd;

cout << 5555

Test cases: 1 2 9999 ==> 1 3 9999=>1 0 1 -2 2 -5 -5 ==> 40 3

1 -2 2 -5 -5 ==> -40 3 -2 7 9 4 3 -84 9999 ==>168 23

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

here) and other areas you consider relevant.

Answered: 1 week ago