1. Engineering
2. Computer Science
3. halix programming c 1 write halix machine code to read...

# Question: halix programming c 1 write halix machine code to read...

###### Question details

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

###### Solution by an expert tutor 