Question

white a program that determines if 3 numbers that are entered, by the user, are sides of a right triangle.

 project 5 functions calling functions

 white a program that determines if 3 numbers that are entered, by the user, are sides of a right triangle.

 remember any combination of numbers can be entered, 3 4 5, 5 4 3, 4 3 5... are all the same right triangle.

 you must have a function that does exponentiation,

 one that does input one that does output.

 and one that does the comparisons

 the main will be this code

 main:

    jal allwork

    li $v0,10

    syscall

 function allwork will call function input which will ask the user for a number,

 input will call function pow which will square the number (it must work with any exponent >=0)

 allwork will also call function check, which will check if it's a right triangle,

 and function print, which will output if it is a right triangle or not.

 some of these functions will be called more than once

 you will need the stack to manage the nested functions, and their return address'.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

.data
stmt:    .asciiz "Enter a: "
stmt1:    .asciiz "Enter b: "
stmt2:    .asciiz "Enter c: "
stmt3:    .asciiz "The sides form a right angled triangle"
stmt4:    .asciiz "The sides doesn't form a right angled triangle"
.globl main
.text
main: jal allwork
exit:   li $v0,10
    syscall
   
allwork: jal input

input:       la   $a0, stmt       # load address of stmt for syscall
           li   $v0, 4           # specify Print String service
           syscall      
       li      $v0,5                   # get an integer from the user
           syscall
       # Store the a value in t0
        move    $t0,$v0
       
        la   $a0, stmt1       # load address of stmt for syscall
           li   $v0, 4           # specify Print String service
           syscall      
       li      $v0,5                   # get an integer from the user
           syscall
       # Store the a value in t0
        move    $t1,$v0
       
        la   $a0, stmt2       # load address of stmt for syscall
           li   $v0, 4           # specify Print String service
           syscall      
       li      $v0,5                   # get an integer from the user
           syscall
       # Store the a value in t0
        move    $t2,$v0
        j pow
       
pow:       mul $s0,$t0,$t0
        mul $s1,$t1,$t1
        mul $s2,$t2,$t2
        j check
check:       add $s3,$s0,$s1
        add $s4,$s2,$s1
        add $s5,$s0,$s2
       
        beq $s3,$s2,true
        beq $s4,$s0,true
        beq $s5,$s1,true
        j false
false:       la   $a0, stmt4      # load address of stmt for syscall
           li   $v0, 4           # specify Print String service
           syscall  
           j exit
true:         la   $a0, stmt3      # load address of stmt for syscall
           li   $v0, 4           # specify Print String service
           syscall  
       
       
        

Output:

Add a comment
Know the answer?
Add Answer to:
white a program that determines if 3 numbers that are entered, by the user, are sides of a right triangle.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assignment Develop a program to analyze one or more numbers entered by a user. The user...

    Assignment Develop a program to analyze one or more numbers entered by a user. The user may enter one or more numbers for analysis. Input should be limited to numbers from 1 through 1000. Determine if a number is a prime number or not. A prime number is one whose only exact divisors are 1 and the number itself (such as 2, 3, 5, 7, etc.). For non-prime numbers, output a list of all divisors of the number. Format your...

  • In C programming language: This program will output a right triangle based on user specified height...

    In C programming language: This program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. (1) The given program outputs a fixed-height triangle using a * character. Modify the given program to output a right triangle that instead uses the user-specified triangleChar character. (1 pt) (2) Modify the program to use a nested loop to output a right triangle of height triangleHeight. The first line will have one user-specified character, such as % or *....

  • in Java This program will output a right triangle based on user specified height triangleHeight and...

    in Java This program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. (1) The given program outputs a fixed-height triangle using a character. Modify the given program to output a right triangle that instead uses the user-specified trianglechar character. (1 pt) (2) Modify the program to use a nested loop to output a right triangle of height triangleHeight. The first line will have one user-specified character, such as % or* Each subsequent line will...

  • (In C++) The program will output a right triangle based on user specified height triangleHeight and...

    (In C++) The program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. Modify the program to use a nested loop to output a right triangle of height triangleHeight. The 1st line will have one user-specified character, such as %or * Each subsequent line will have 1 additional user-specified character until the number in the triangle"s base reaches triangleHeight. Output a space after each user-specified character, including after the line"s last user-specified character. Example output...

  • MUST BE WRITTEN IN C++ All user input values will be entered by the user from...

    MUST BE WRITTEN IN C++ All user input values will be entered by the user from prompts in the main program. YOU MAY NOT USE GLOBAL VARIABLES in place of sending and returning data to and from the functions. Create a main program to call these 3 functions (5) first function will be a void function it will called from main and will display your name and the assignment, declare constants and use them inside the function; no variables will...

  • 1. Prompt the user for one of the arithmetic operators ('op'): +, -, *,/, or **...

    1. Prompt the user for one of the arithmetic operators ('op'): +, -, *,/, or ** 2. Prompt the user for two input integers ('a' and'b') 3. The input numbers can be positive or negative 4. Perform the arithmetic operation using the two input numbers 5. The first entered number ('a') is the left side, the second ('b') the right side of the operation For exponentiation, the first number is the base, the second the exponent Print (display) the following...

  • code in c please Concepts to Practice User-written functions math.h Description For the prelab assignment, you...

    code in c please Concepts to Practice User-written functions math.h Description For the prelab assignment, you are to write a function to calculate Power (exponentiation). Your function will be called MyPower. MyPower() will raise a given double type number to a positive integer power. You may NOT call any function from math.h such as pow) in your implementation of MyPower) The main) function in your program should look exactly like this: int main(void) int i,j; for (i-1;i<5;i++) { for (j-1;j<5;j++)...

  • Q.1. Write a C program that determines whether a line entered by a user is a...

    Q.1. Write a C program that determines whether a line entered by a user is a palindrome or not. You must demonstrate it as an application of stack (you may use linked list implementation demonstrated in the class). Hint! Think of the basic property of a stack i.e. LIFO (list-in-first-out). Q.2. Write a charQueue header file containing all the function headers of following functions: 1- initiateQueue—to initialize a queue 2- enqueue—to add a node at the rear end of the...

  • You must write a C program that prompts the user for two numbers (no command line...

    You must write a C program that prompts the user for two numbers (no command line input) and multiplies them together using “a la russe” multiplication. The program must display your banner logo as part of a prompt to the user. The valid range of values is 0 to 6000. You may assume that the user will always enter numerical decimal format values. Your program should check this numerical range (including checking for negative numbers) and reprompt the user for...

  • Lottery Game (15 Numbers). Design and implement a C++ program that generates 15 random non-repeating positive...

    Lottery Game (15 Numbers). Design and implement a C++ program that generates 15 random non-repeating positive integer numbers from 1 to 999 (lottery numbers) and takes a single input from the user and checks the input against the 15 lottery numbers. The user wins if her/his input matches one of the lottery numbers. Your implementation must have a level of modularity (using functions) Functions you need to implement: Define function initialize() that takes array lotterNumbers[] as a parameter and assigns...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT