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
son4ous [18]
3 years ago
9

Given the following code fragment, how many times does the loop body execute? int laps = 50; int myNum = 1; do { myNum = myNum +

2; laps = laps + 1; } while(laps <= 1);
Computers and Technology
1 answer:
Jlenok [28]3 years ago
8 0

Answer:

one

Explanation:

The loop is used to execute the part of code or statement again and again until the condition is not FALSE.

There are three types of loop in programming.

1. for loop

2.while loop

3. do-while loop

Do-while has one special property which makes it different from other loops.

The loop statement executes once if the condition of the loop is failed in the starting.

In do-while, the statement executes first and then while checking the condition.

let discuss the code:

initially, laps=50, myNum=1

then, the program executes the statement in the loop.

so, myNum = 1 + 2=3.

A value 3 is assign to the variable myNum.

laps = 50 + 1=51.

A value 3 is assigned to the laps variable.

then while checking the condition (51 <= 1) which is FALSE.

The program terminates the loop.

Therefore, the answer is one.

You might be interested in
What is the difference page break and column break ​
algol13
A page break starts a new page. A column break starts a new column, while a section break indicates a change in formatting within the same page.
7 0
3 years ago
Read 2 more answers
with the current computer development, explain 5th areas where computer is applied for the social economic dwvelopment in societ
AleksandrR [38]

Explanation:

just want points tbh but have a good day

7 0
3 years ago
Write a c program that reprints input so that no line is longer than 50 characters. Specifically, for lines less than or equal t
Alex73 [517]

Using the knowledge in computational language in C++ it is possible to write a code that reprints prints input so that no line is longer than 50 characters.

<h3>Writting the code:</h3>

<em>#include<stdio.h></em>

<em />

<em>int main(int argc, char** argv){</em>

<em>    //creating pointer to read a file</em>

<em>    FILE * fp;</em>

<em>    char * line = NULL;</em>

<em>    size_t len = 0;</em>

<em>    ssize_t read;</em>

<em>    int i=0;</em>

<em>    //opening a file</em>

<em>    fp = fopen(argv[1], "r");</em>

<em>    //handling the error condition</em>

<em>    if (fp == NULL){</em>

<em>        printf("File not found..!!");</em>

<em>        return 0;</em>

<em>    }</em>

<em>    int moreThan50 =0;</em>

<em>    //reading a file line by line</em>

<em>    while ((read = getline(&line, &len, fp)) != -1) {</em>

<em>        i = 0;</em>

<em>        if(read >= 50){</em>

<em>            moreThan50++;</em>

<em>        }</em>

<em>        while(i < read){</em>

<em>            if(line[i]!='\n'){</em>

<em>                if(i%50 == 0){</em>

<em>                    printf("\n%c",line[i]);</em>

<em>                }else{</em>

<em>                    printf("%c",line[i]);</em>

<em>                }</em>

<em>            }</em>

<em>            i++;</em>

<em>        }</em>

<em>    }</em>

<em>    printf("\nTotal lines over 50 chars: %d\n",moreThan50);</em>

<em>    printf("Offending Lines: ");</em>

<em>    for(i=1;i<=moreThan50;i++)</em>

<em>        printf("%d, ",i);</em>

<em>    fclose(fp);</em>

<em>    return 0;</em>

<em>}</em>

See more about C++ at brainly.com/question/19705654

#SPJ1

4 0
2 years ago
The function of a start winding in a split-phase motor is to A. provide the starting torque. B. reduce the starting current. C.
gulaghasi [49]
The most appropriate answer is A, the the start winding on a split-phase motor is to provide a starting torque. A split-phase motor is a single phase electrical motor (common in many household applications such as washing machines and household fans), with two distinct windings on the stator coils, the start windings and the run windings, at 90 degrees apart. When the motor is energised the start coils acts like a second phase (2 phase motor) and helps provide the rotating magnetic field that is necessary to turn the rotor. Once moving, only the run winding (single phase) is required to keep the motor spinning.

The other answers are irrelevant for the starting of the motor.
4 0
3 years ago
Interpret the poem 'the popular field'as a definse of natural conservation​
olga2289 [7]

Answer:

<em><u>Consider the poem “The Poplar Field” as a defense of nature conservation. This poem is a defense of nature conservation. The poet's message is that trees shouldn't be cut down recklessly. ... The poet also says that though we can plant trees, they don't grow as fast as the trees are being cut down in the present time.</u></em>

Explanation:

7 0
3 years ago
Other questions:
  • If you want to conserve ink or toner, you can instruct PowerPoint to print ____ documents.
    10·1 answer
  • Have main create two objects: setA and setB.Input the values into setA (end with a 0 or negative) and input the values into setB
    12·1 answer
  • Write a program to check if an input is a valid hashtag (starts with #, contains only letters, numbers, and underscore, no space
    6·1 answer
  • Give an example of a situation in which shears would be the best choice and one in which scissors would suffice.
    14·1 answer
  • In an e-credit card transaction the clearinghouse plays the following role:
    6·2 answers
  • Which programming language was released first
    7·1 answer
  • What do you expect the future trends of an operating system in terms of (a) cost (b) size (c) multitasking (d) portability (e) s
    12·1 answer
  • Write short notes about monitor printer and speaker​
    14·2 answers
  • Consider the key success factors of B2C. Is it only IT? What is most important?​
    8·1 answer
  • What is keyword density?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!