Computer programming

posted by .

Set k=1
While k<=5
Display k + 1
End While

In the above what gets displayed

Set k=1
While k<=5
k = k + 2
End While

In the above how many times is the loop executed

For x = 0 To 5
Display x
End For

How many times will the above loop get executed…what will it print

  • Computer programming -

    For the first question, the loop runs 5 times, just count it on your fingers. It will display 23456

    For the second question, the loop runs three times. Once when k = 1, once when k = 3, and once when k = 5.

    For the third question, it will either run 5 or 6 times...I am not familiar with this syntax. If the loop will run when x = 5, then 6 times. If not, then only five.
    Also, if it will run when x = 5, then the output will be:
    012345
    otherwise, it will be:
    1234

    Hope this helps!

  • Computer programming -

    Set k=1
    While k<=5
    Display k + 1
    End While

    k does not get updated inside of the while loop, so it will print 2 and loop forever.



    Set k=1
    While k<=5
    k = k + 2
    End While

    When it hits "while k<=5", the values of k are
    1,3,5,7...
    So how many times does it get executed?

    For x = 0 To 5
    Display x
    End For
    By definition of the for loop, it executes 6 times and displays the 6 integers.

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. Computer Programming

    I was wondering if someone could review my pseudocode to see if I got this right. Here is the question: Input a list of employee names and salaries, and dtermine the mean (average) salary as well as the number of salaries above and …
  2. programmning code

    Is this code right? Declare Integer days, counter = 1 Declare Real penny = 1, salary, total = 0 Display "Enter a number of days." Input days Display "Days",TAB,"Salary While counter <= days Set salary = penny/100 Display counter,
  3. Programming

    Design a program in pseudocode that calculates the amount of money a person would earn over a period of time if their salary is one penny the first day, and then doubles each day. The program should ask the user for the number of days. …
  4. Programming

    Design a program in pseudocode that calculates the amount of money a person would earn over a period of time if their salary is one penny the first day, and then doubles each day. The program should ask the user for the number of days. …
  5. English

    1. While he was based on the sketches, Degas painted in his studio. 2. While he was walking on the street, he met a friend of his. 3. While he was driving, he sometimes smoked. 4. While he was chatting, he drank coffee from time to …
  6. programming logic and design

    what is the output by each psuedocode segments ?
  7. programming logic and design

    whats is the output for each psuedocode sedment?
  8. programming

    I am supposed to make a pseudocode for a fat gram calculator and I want to know if my code is correct. This is the instructions: Design a program that asks for the number of fat grams and calories in a food item. Validate the input …
  9. Is My Pseudocode Correct? - Programming

    I am supposed to make a pseudocode for a fat gram calculator. These are the instructions: Design a program that asks for the number of fat grams and calories in a food item. Validate the input as follows: - Make sure the number of …
  10. programming

    Example Develop a pseudocode algorithm for a program that accepts each of the average marks of 10 students in a class and computes the sum and the average mark of the class. The program should display the average mark of the class. …

More Similar Questions