Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that asks the user to enter the number of even integers that needs to be added together. Then you use the loop
Write a program that asks the user to enter the number of even integers that needs to be added together. Then you use the loop to get the integers from user and add the even numbers together. Finally your program should output the sum on the screen.
NO LONGER NEED HELP... FIGURE IT OUT
I'm using mips simulator. I have an error on code: Won't print out Sum
num: . asciiz "How many even numbers would you like to add together?" SUM: .asciiz "nThe Sum of the number is: .text main: #print num li $v0, 4 la $al, num syscall #input how many even numbers li $v0, 5 syscall li $t6, 0 add $t2, $v0, $0 #loop begin loop: li $50,0 #sum 0 beq $50,$t2, done li $v0, 5 syscall add $t0,$v0,$0 div $t0,$t0,2 mfhi $to beq $t0,0, evenlumber j skip evenlumber: add $t6,$t6, $v0 add $50, $50,1 skip: j loop done: li $v0, 4 la $al, sum syscall add $a0,$t6,90 li $v0,1 exit: li $v0, 10 syscall num: . asciiz "How many even numbers would you like to add together?" SUM: .asciiz "nThe Sum of the number is: .text main: #print num li $v0, 4 la $al, num syscall #input how many even numbers li $v0, 5 syscall li $t6, 0 add $t2, $v0, $0 #loop begin loop: li $50,0 #sum 0 beq $50,$t2, done li $v0, 5 syscall add $t0,$v0,$0 div $t0,$t0,2 mfhi $to beq $t0,0, evenlumber j skip evenlumber: add $t6,$t6, $v0 add $50, $50,1 skip: j loop done: li $v0, 4 la $al, sum syscall add $a0,$t6,90 li $v0,1 exit: li $v0, 10 syscallStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started