Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8562847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:49:18+00:00 2026-06-11T16:49:18+00:00

I need to take input from the user a floating point array and then

  • 0

I need to take input from the user a floating point array and then print it. I tried the following code:-

.text
.globl main
main:

 la $s0,size
 lw $s1,0($s0)      # size in $s1
 ori $s2,$zero,0    # i in $s2
 la $s3,arr         # arr in $s3

 li $v0,4
 la $a0,msg1
 syscall

 L1:
  beq $s2,$s1,DONE
  li $v0,6
  syscall
  swc1 $f0,0($s3)
  j UPDATE

 UPDATE:
  addi $s3,$s3,4
  addi $s1,$s1,1
  j L1

 DONE:
  li $v0,4
  la $a0,msg2
  syscall

  la $t0,arr
  ori $t1,$zero,0
  L2:
   beq $t1,$s1,EXIT
   lwc1 $f20,0($t0)
   li $v0,2
   mov.s $f12,$f20
   syscall
   addi $t0,$t0,4
   addi $t1,$t1,1
   j L2

  EXIT:
  li $v0,10
  syscall
    .data
  size: .word  9
  arr:  .float  0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0 
  msg1: .asciiz "Enter the elements:-"
  msg2: .asciiz "The elements are:-"  

When i give the input, there is a runtime exception ‘invalid float input’ at syscall 6. Please help!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:49:19+00:00Added an answer on June 11, 2026 at 4:49 pm

    I guess you are using , as the decimal point instead of ..

    E.g.: instead of entering 3.14159 you are entering 3,14159 which is not expected at least by MARS.

    Aside from that, I think the line addi $s1,$s1,1 in your code should be addi $s2,$s2,1, as you seem to be using $s2 to hold the current value of your index counter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my project i need to take an expression input from user as string
i need to take user input and make a very simple bar graph from
In my application, I need to take input from the user for a column
I have a homework assignment where I need to take input from a file
I take a regular expression as an input from the user and match values
I would like to create a triangle and take user input from the user.
I wanted to take Numeric input from user from Numberpad displayed on screen, it
How to make this piece of code loop asking for input from the user
I need to process the input from the user in a console application, and
I have written a code to take an input from a file of very

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.