Question

In the script below, where should I insert the break command so that the code produces...

In the script below, where should I insert the break command so that the code produces the following output:
10
    11

    12

    26
 
 
a = 10; for i=a:i+10 if( a<13 ) ...(1)... disp(a); a = a+1; ...(2)... else disp(a*2); ...(3)... end ...(4)...  end

a.

(4)

b.

(1)

c.

(3)

d.

(2)

Homework Answers

Answer #1

Answer:

c.

(3)

Explanation:

The given script is:

a = 10; for i=a:i+10 if( a<13 ) ...(1)... disp(a); a = a+1; ...(2)... else disp(a*2); ...(3)... end ...(4)...  end

For the first three passes of the for loop, the first if block will be executed and 10 11 12 will be printed. For the fourh pass the program will go inside the else statement where the value of a is 13 currently and 13*2 i.e. 26 will be printed. After that we should give the "break" keyword in order to stop execution at that time according to the given problem.

Know the answer?
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
Similar Questions
Write a command sequence or a script to insert a line “GHIJKLM” at every 10th line...
Write a command sequence or a script to insert a line “GHIJKLM” at every 10th line of a file? I am using this on Docker Quickstart Terminal version 19. I can't seem to execute it on the command line or get it to work. I'm not sure what I have to fix. This is what I have written so far. ---------------------------------------------------- JennyM07@DESKTOP-3XD60LM MINGW64 ~/CIT270/Lab_1$ ls -l total 1 -rwxr-xr-x 1 JennyM07 197121 100 Aug 26 21:41 file8.sh* -rw-r--r-- 1 JennyM07...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for a non-negative integer value a. The script should then evaluates the sum Pn i=1 i a using a running sum for the case when n = 5. More specifically, use a counter for i that is used in the output fprintf as well as in the running sum. Feel free to write some code and just repeat it 5 times in your script. Sample...
For MATLAB I am trying to make a code for Russian Roullette where the player can...
For MATLAB I am trying to make a code for Russian Roullette where the player can choose how many bullets (Maximum of 6) they want to load increasing and decreasing the chances of being eliminated each spin. This is the code I have so far. I need to have multiple scenarios where the probability is decreased with each extra bullet loaded into the chamber up until 6 which by that point, the chance of being eliminated is 100% A=input('select chamber...
Take a look at the code below. What is the problem with the code? Change the...
Take a look at the code below. What is the problem with the code? Change the code so that it will run properly. (10 points) i = -6 # Code the while loop while i != 0 :     print("Output 1")     if i>0 :           print("Output 2")     else :           print("Output 3")    print(offset)
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for an integer between 0 and 9999, inclusive. The script should then calculate the digit in each of the 1000’s, 100’s, 10’s, and 1’s place of the number. Create a variable for each of the 4 extracted digits. For example, if your variables are named nThousands, nHundreds, nTens, and nOnes, then, in the case of 9471, they would be end up being set to 9,...
Python Script 2.7 Please insert a screenshot of the script as a way to make sure...
Python Script 2.7 Please insert a screenshot of the script as a way to make sure it does run. Write a program that asks the user to enter the names and times (in seconds) for 3 people entered in the 100 meter dash. Your program should print out the name of the winner. You are guaranteed that no one will tie with anyone else, so that there will always be a clear winner. Sample Program Run Runner #1, what is...
i want to complete this code to insert a new node in the middle of list...
i want to complete this code to insert a new node in the middle of list (take a node data from user, search the node and insert new node after this node). this is the code #include <iostream> #include <stdlib.h> using namespace std ; struct Node{                int data;                Node *link ;}; struct Node *head=NULL, *tail=NULL; /* pointers to Node*/ void InsertFront(); void InsertRear(); void DeleteFront(); void DeleteRear(); int main(){                int choice;                do{                               cout << "1:...
In assembler code must be a gcd.s file So here is the C code I have...
In assembler code must be a gcd.s file So here is the C code I have written originally for the program. My question is how do I convert it to assembly code? //C code #include <stdio.h> int fibonacci(int n) { if(n <= 2) { return 1; } else { return fibonacci(n-1) + fibonacci(n-2); } } int main(void) { int n; printf("Enter Fibonacci term: "); scanf("%d", &n); printf("The %dth Fibonacci number is %d\n", n, fibonacci(n)); return 0; } Instructions In C...
In the Python code below, use the array built to shuffle and deal TWO cards for...
In the Python code below, use the array built to shuffle and deal TWO cards for THREE  poker hands. Change the corresponding values for all Jacks through Aces to 11, 12, 13, 14 respectively. Shuffle the deck using your written shuffle routine, then deal THREE hands.   Deal two cards for three hands Computer the total card value per hand. Add a function that will determine whether the amount of the hand is Less than 17, if so add a card and...
I have written working code for this problem however it is not producing an output and...
I have written working code for this problem however it is not producing an output and it states is a wrong answer. Please just fix my code below and make it work for the sample test cases and all test cases. You are given a pointer to the root of a binary search tree and values to be inserted into the tree. Insert the values into their appropriate position in the binary search tree and return the root of the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT