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
malfutka [58]
3 years ago
11

11.

Computers and Technology
1 answer:
kodGreya [7K]3 years ago
6 0

Answer:

The basic difference between finite and infinite is the number of times it runs and ends. The loop is basically a set of instructions that keeps repeating itself.

The finite loop ends after running for a finite times. This body of finite loop will stop executing after certain condition is reached. Hence the finite loop body keeps executing itself finite number of times.

An infinite loop keeps running and repeating itself endlessly.This loop never ends. This loop can be the result of an error in a program. For example when no stopping or exit condition is specified in the program.

Explanation:

Example of finite loop:

Lets take for loop as an example:

for(int i =0; i<=5; i++)

{ cout<<i<<endl; }

Now the loop starts from i=0

Next it enters the body of loop to execute the statement: cout<<i; which means that the value of i is displayed on the output screen.

This loop keeps executing until the value of i exceeds 5.

At first iteration 0 is printed on the output screen, at second iteration 1, at third iteration 2, at fourth iteration 3, fifth iteration 4, sixth iteration 5. After each of these iterations, the value of i is incremented by 1.

When 5 is printed, then at the next iteration the specified condition i.e. i<=5 gets false as the value of i now becomes 6 after incremented by 1.

So the loop stops running. So this means that loop ran for finite times and stopped after the a certain condition is reached. The output is:

0

1

2

3

4

5

Example of infinite loop:

Lets take while loop:

int i = 6;

    while (i >=5)

    {         cout<< i;

             i++;     }

In the above example, the loop will run infinite times. Here the value of i is initialized to 6. Then while loop is used which checks the condition which is the value of i is greater than or equal to 5. If the condition is true, the body of the loop starts executing which prints the value of i. Lets see what happens at each iteration:

1st iteration: i>=5 is True because i=6 and 6 is greater than 5. The program control enters the body of loop. The statement cout<<i prints 6. Next the value of i is incremented by 1 and it becomes 7.

2nd iteration: i>=5 is True because i=7 and 7 is greater than 5. The program control enters the body of loop. The statement cout<<i prints 7. Next the value of i is incremented by 1 and it becomes 8.

This loop will repeat itself infinite times and never stops as i will always have value greater than 5. So this is the example of infinite loop.

You might be interested in
Capacity requirements are computed by multiplying the number of units scheduled for production at a work center by the:
podryga [215]

Answer:

.

Explanation:

5 0
3 years ago
Using Sequential Search on an array of size n, the search key is definitely present in the array. The probability of matching th
MissTica

Answer:

(11n-5) / 12 is correct answer.

Explanation:

The Probability that key will match to nth term = 1/2

The Probability that key will match to n-1th term = 1/3

As all other probabilities are equal

The Total Probability that key matches to any of 1 to n-2 index = 1 - 1/2 - 1/3 = 1/6

The Probability that key matches to any of 1 to n-2 index = (1/6) / n-2 = (1/6)* (n-2))

Let P(i) = Probability that key matches to ith index.

The Average time complexity = 22 i=1 P(i) * i

The Average time complexity = 1/(6(n-2) * ( sum of 1 to n-2 ) + (n-1) / 3 + n/2

The Average time complexity = 1/(6(n-2) * ( n-2)*(n-1) / 2 + ( n-1) / 3 + n/2

The Average time complexity = 1/6 * (n-1)/2 + (n-1)/3 + n/2

The Average time complexity = (n-1)/12 + (n-1)/3 + n/2

The Average time complexity = (n-1 + 4 * n - 4 * 1 +6 * n)/12

The Average time complexity = 11n-5 / 12

so (11n-5) / 12 is correct answer.

7 0
3 years ago
What term is used for a seemingly harmless program that has malicious code hidden inside?
Delicious77 [7]
That is none other than a "Trojan Horse"
8 0
3 years ago
The formatting option functions like space bar. However instead of moving one space at a time, it allows you to move your text i
Schach [20]
What are the options???
4 0
3 years ago
How many channels can the 2.4 GHz band be divided into?
wlad13 [49]

Answer:Fourteen channels

Explanation:

8 0
3 years ago
Other questions:
  • The combination of two or more technologies or data feeds into a single, integrated tool is referred to as a _____.
    7·1 answer
  • What is the difference between HTML and CSS? * 1. CSS is a markup language unlike HTML. 2. HTML is a backend technology and CSS
    12·2 answers
  • You are given two processors P1 and P2 that execute the same instruction set but have different architectures. The instructions
    9·1 answer
  • Which email client feature allows you to store the names and information of people you contact frequently?
    5·1 answer
  • A digital certificate system: Group of answer choices uses digital signatures to validate a user's identity. is used primarily b
    13·1 answer
  • As a general rule, what is the size of a brochure?
    11·1 answer
  • Assume the availability of a function is_prime. Assume a variable n has been associated with positive integer. Write the stateme
    15·1 answer
  • The term packet is used fairly generically to refer to protocol data unit (PDU). There are PDU equivalent names in the different
    15·1 answer
  • Write a program that reads a file called 'test.txt' and prints out the contents on the screen after removing all spaces and newl
    7·1 answer
  • HELP FAST
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!