1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Basile [38]
3 years ago
11

How I to turn this ''loop while'' in ''loop for''? var i = 0; while (i < 20) { var lineY = 20 + (i * 20); line(0, lineY, 400,

lineY); i++; }
Computers and Technology
1 answer:
Fudgin [204]3 years ago
5 0

Answer:

for(i = 0; i<20;i++){

lineY = 20 + (i * 20);

line(0, lineY, 400, lineY) }

Explanation:

First declare and initialize the variable i. You have not specified the data type of i so if the data type of i is integer i.e. int then you should declare i variable in the for loop as for(int i = 0; i<20;i++)

So the given while loop has a variable i which is initialized to 0. Then while(i<20) means that while loop executes until the value of i exceeds 20. If this while condition is true then the two statements inside its body will execute. The two statements are: lineY = 20 + (i * 20);

line(0, lineY, 400, lineY);

The value of i ins incremented after each iteration i.e. i++

So while loop has the following syntax"

1) initialization;  ---->  i = 0

2) while(condition) {  ----> i<20

3) loop body ----->  lineY = 20 + (i * 20); line(0, lineY, 400, lineY);

4) increment or decrement loop variable  } ----> i++

For loop has the following syntax:

for( initialization of loop variable ; condition; decrement/increment loop variable)  {

loop body }

Here:

initialization  ---->  i = 0

condition        ----> i<20

loop body     -----> lineY = 20 + (i * 20); line(0, lineY, 400, lineY);

increment or decrement loop variable  ---->  i++

You might be interested in
1: define about information system in computer?
kobusy [5.1K]

Explanation:

1. Information system is a collection of people, procedures, software, hardware, and data to provide essential information to run an organization.

2. Thesaurus is a software tool used in Microsoft Word document to provide synonyms and antonyms for a selected word.

3. Computer component refers to a basic physical element that is required by the computer to function.

5 0
3 years ago
The most commonly used video formats are the mpeg-____ format, the windows media audio/video format, and the audio visual interl
Archy [21]
<span>The answer is mpeg-4.  The most commonly used video formats are the mpeg-4 format, the windows media audio/video format, and the audio visual interleave format.</span>
8 0
4 years ago
For this step, submit your work in the programming environment by
Tems11 [23]

Answer:

is there some oppsense you can choose from

7 0
3 years ago
Choose all that apply.
stiks02 [169]

Answer:

choose all that apply

Explanation:

7 0
3 years ago
How do I type over Images (photo posted ​
Ber [7]
Oh a document, I do not believe that you have type on images, but if you were to type a text in a app called PicsArt and saved it and then put it onto the document over the picture it would work.
3 0
3 years ago
Read 2 more answers
Other questions:
  • Print "Censored' if userlnput contains the word "darn, else print userlnput. End with newline. Ex: If userinput is "That darn ca
    11·1 answer
  • ____, developed by xuejia lai and james massey, is a block cipher that operates on 64-bit blocks of plaintext.
    10·1 answer
  • Direct connections provide continuous access to the Internet. Many bandwidth options are associated with direct connections. Whi
    9·1 answer
  • What are the synonyms for each word? :
    5·1 answer
  • Write four overloaded methods called randomize. Each method will return a random number based on the parameters that it receives
    5·2 answers
  • Walmart store wants to compare the sales of five of its stores. Write a complete program to ask the user to enter the sales for
    12·1 answer
  • What PowerShell command can be used to clean up old update files on a WSUS server, including unused update files, old revisions,
    10·1 answer
  • In working on the conceptual design of the new database, Ken determines that the "office" field in one of the tables must includ
    8·1 answer
  • In a singing competition, there are 34 more men than women
    5·2 answers
  • Tyra is peer conferencing about her project with a friend. Tyra's friend provided feedback that Tyra does not agree with. What s
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!