Create a loop to display all even numbers from 0 to 100. Describe the three elements that must be included in order for a loop to
perform correctly. What will happen if these statements are not included? Provide examples.
The three elements that must be included in order for a loop to perform correctly. What will happen if these statements are not included? Provide examples

See Answers (1)

Suggested Answer

A loop to display all even numbers from 0 to 100:for(i= 0;i<= 100; i++) {          if(counter%2 == 0) {            printf("%d ",i); The loop consists of three important parts: the initialization: the keyword that starts the loopthe condition: the condition being testedthe update: for each iteration.By missing a condition statement in a for loop, it would loop forever.Example:void main() {  int i = 10;for( ; ;) {printf("%d\n",i); }}As in the above code, the for loop is running for infinite times and printing the i value that is 10 infinitely.What is a for loop used for?A "For" Loop is used to repeat a specific block of code a known number of times. What are the main types of loops?There are two types of loops, “while loops” and “for loops”. While loops will repeat while a condition is true, and for loops will repeat a certain number of times.What are the elements of a loop? Loop statements usually have three components: initialization, condition, and update step, and it contains a loop body.To know more about loop:https://brainly.com/question/16922594#SPJ1

Related Question in Computers and Technology