Question 5: (back)
Write a program that computes (n)(n+1)/2. It should read the value "n" from the user. Hint: you can compute this formula by adding up all the numbers between one and n.
program Question5; #include( "stdlib.hhf" ); static i: int8; // counter n: int8; // number a: int8; // answer begin Question5; stdout.put( "Enter a number: " ); stdin.get( n ); mov( n, al ); mov( 1, i ); mov( 0, a ); while( i <= al ) do mov( a, bl ); add( i, bl ); mov( bl, a ); inc( i ); endwhile; stdout.put( nl, "(", n, ")(", n, "+1)\2 = ", a, nl); end Question5;