Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
College aantekeningen

C++ Programming Handling Repetitions For Loop Statement

Beoordeling
-
Verkocht
-
Pagina's
4
Geüpload op
28-10-2021
Geschreven in
2020/2021

Learn about the concepts of C++ Programming Handling Repetitions For Loop Statement

Instelling
Vak

Voorbeeld van de inhoud

C++ PROGRAMMING: HANDLING REPETITIONS FOR
LOOP STATEMENT

Loop statements in C++ execute the certain block of the code or statement multiple times, mainly used to
reduce the length of the code by executing the same function multiple times, reduce the redundancy of the code.
C++ supports various types of loops like for loop, while loop, do-while loop, each has its own syntax,
advantages, and usage.

In the programming world, the loop is a control structure that is used when we want to execute a block of code,
multiple times. It usually continues to run until and unless some end condition is fulfilled.

After doing this module, you are expected to:

1. Identify the flow of control using for loop statement
2. Use the for loop statement to formulate loop statements
3. Create a program using the for loop statement to satisfy certain problem

INTRODUCTION
In Kafka’s Metamorphosis, salesman Gregor Samsa led a boring, repetitive life—until he woke up one rainy
morning to find himself transformed into a giant cockroach. It is human nature to get bored and to lose interest
in certain activities if these have been done repeatedly for a very long time. Of course, just because we’re bored
doesn’t mean that we will immediately transform into vermin. However, doing anything repetitively over a long
period of time does lead to fatigue and inattention on the part of the person.
Monotony and boredom over highly repetitive tasks usually cause either or both of the following: (a) the person
loses concentration and begins to commit careless mistakes, or (b) he quits and walks away from the job. One of
the greatest strengths of a computer is its ability to perform repetitive tasks continuously without getting bored
or tired. With computers, we only have to worry about our own fatigue.
But just exactly how are such repetitive tasks handled in computer programs? Using only sequential and
selection control structures, one way of accomplishing the repeated execution of a particular operation is by
typing the same code in the program over and over again. This is an extremely inefficient or even unworkable
way of doing it.
Fortunately, there are repetition control structures specifically meant to handle the repeated execution of
portions of a program. These control structures are called loops. With loops, a test condition for repetition is
already built-in, and a separate goto statement is no longer required. Each pass through the loop is called
an iteration.


DISCUSSION

Counter-Controlled Loops
A counter-controlled loop is a control structure that allows us to specify the repeated execution of a group of
program statements a definite number of times. A variable that serves as an index or counter is used to indicate
how many times an enclosed block of statements is to be executed repeatedly.

for loop
A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a
specific number of times.

The syntax of a for loop in C++ is :

for ( init; condition; increment )

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
28 oktober 2021
Aantal pagina's
4
Geschreven in
2020/2021
Type
College aantekeningen
Docent(en)
Nani madriaga
Bevat
Alle colleges

Onderwerpen

$4.49
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
sophiamadriaga

Maak kennis met de verkoper

Seller avatar
sophiamadriaga
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
4 jaar
Aantal volgers
0
Documenten
9
Laatst verkocht
-

0.0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen