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

  • Home
  • SEARCH
  • 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 9021501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:16:13+00:00 2026-06-16T05:16:13+00:00

Consider the following code x = y+3; y = input(‘??’); What can I do

  • 0

Consider the following code

x = y+3;

y = input(‘??’);

What can I do to ask the user to continue or not, if yes then it prompt the input function for y again, if no then terminate the program.

  • 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-16T05:16:14+00:00Added an answer on June 16, 2026 at 5:16 am

    Try this:

    while true
      % Do stuff
      inp = input('Continue? (y/n) ', 's');
      if ~strcmp(inp, 'y')
        break;
      end
    end
    

    Edit: Based on our discussion, I’m adding an example of how you could structure a Matlab file with two functions, a main function running the above loop, and a helper function that is called inside the loop.

    function main()
      while true
        inp = input('Enter y: ', 's');
        y = str2double(inp);
        helper(y)
        inp = input('Continue? (y/n) ', 's');
        if ~strcmp(inp, 'y')
          break;
        end
      end
    end
    
    function helper(y)
      x = y + 3;
      fprintf('x = %.2f\n', x);
    end
    

    More info on Matlab functions here.

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

Sidebar

Related Questions

Consider the following code which takes an integer input and then prints the cin
Consider the following code snippet that takes user input (a date) and format it
Consider the following code : HTML: <input type='checkbox' /> <div>Click here</div> JS: $(function() {
Consider following code: My problem is: 1) I can't seem to cast the errors
Consider the following code: $(document).ready(function() { $(body).append(<div class='outer'><span class='inner'>Click me</span></div>); $(html).click(function(event) { var targetClass
Consider the following code: struct TrainingExample { array<double, N> input; array<double, M> output; };
Consider the following HTML5 code in body: <p id=p1> Email: <input type=text name=email /><br
Consider the following code ( http://jsfiddle.net/FW36F/1/ ): <input type=checkbox onchange=alert(this.checked)> <button onclick=document.getElementsByTagName('input')[0].checked=!document.getElementsByTagName('input')[0].checked;>toggle</button> If you
Consider the following code : HTML: <div> <label for='name'>Name:</label> <input type='text' id='name' /> </div>
Consider the following code: class Sample{ public static void main(String args[]){ String text1=C:\Documents\User\sample; String

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.