Share
Go down
avatar
Guru
Posts : 10
Join date : 2018-08-16
View user profile

Re: Using Loop Control Variable

on Thu Aug 16, 2018 10:30 am
daniella wrote:
Rhei wrote:thank you po maam sa matyagang pagtuturo sa amin! Very Happy

hahaha kailangan para pumasa joke. Smile) love ko kayo kahit di niyo ko love sad Wink Sad Very Happy
Love ka namen maam kahit na ginugulo ka namen sa lesson mo po. Laughing Laughing Laughing

SIGE! Very Happy hahaha
avatar
Newbie
Posts : 3
Join date : 2018-08-16
View user profile

Re: Using Loop Control Variable

on Thu Aug 16, 2018 10:34 am
daniella wrote:To make a while loop end correctly, you can declare a loop control variable to manage the number of repetitions a loop performs.
Three separate actions should occur using a loop control variable:

-The loop control variable is initialized before entering the loop.
-The loop control variable’s value is tested, and if the result is true, the loop body is
entered.
-The loop control variable is altered within the body of the loop so that the tested
condition that follows while eventually is false.


Commonly, you can control a loop’s repetitions in one of two ways:

-Use a counter to create a definite, counter-controlled loop.
-Use a sentinel value to create an indefinite loop.


Using a Definite Loop with a Counter





A counter is any numeric variable that counts the number of times an event has occurred.

The illustration below shows a loop that displays Hello four times. The loop is a counted loop, or counter-controlled loop , because theprogram keeps track of the number of loop repetitions by counting them.





A counted while loop that outputs Hello four times

1. The loop control variable, count , is initialized to 0.
2. The while expression compares count to 4.
3. The value of count is less than 4, and so the loop body executes. The loop body shown in Figure consists of two statements that display Hello and then add 1 to count .
4. The next time the condition count < 4 is evaluated, the value of count is 1, which is still less than 4, so the loop body executes again. Hello is displayed a second time and count is incremented to 2, Hello is displayed a third time and count becomes 3, then Hello is displayed a fourth time and count becomes 4.


Using an Indefinite Loop with a Sentinel Value




Consider an interactive program that displays Hello repeatedly as long as the user wants to continue. The loop is indefinite because each time the program executes, the loop might be performed a different number of times.


An indefinite while loop that displays Hello as long as the user wants to continue

In the program in Figure , the loop control variable is shouldContinue . The program executes as follows:

1. The first input shouldContinue statement in the application in Figure is a priming input statement. In this statement, the loop control variable is initialized by the user’s first response.
2. The while expression compares the loop control variable to the sentinel value Y .
3. If the user has entered Y , then Hello is output and the user is asked whether the program should continue. In this step, the value of shouldContinue might change.
4. At any point, if the user enters any value other than Y , the loop ends. In most programming languages, simple comparisons are case sensitive, so any entry other than Y, including y, will end the loop.



Typical executions of the program in Figure 5-4 in two environments.

So pwede ko din pong ilapit ang value ng Initial Value kung gusto kong saglit lang na Loop ang mangyayari ?
Kunwari po nag Initiate ako ng Initial Value na 3 tapos itetest lang ng program ay 4, bali isang ikot lang po sya.
Guru
Posts : 10
Join date : 2018-08-16
View user profile

Re: Using Loop Control Variable

on Thu Aug 16, 2018 10:39 am
maam pwede kapa pobang mag bigay ng example sa control variable loop ?
Guru
Posts : 10
Join date : 2018-08-16
View user profile

Re: Using Loop Control Variable

on Thu Aug 16, 2018 10:43 am
Rfrancis03 wrote:maam pwede kapa pobang mag bigay ng example sa control variable loop ?
Yes nga maam para masmaintindihan namin ung topic :3
avatar
Posts : 1
Join date : 2018-08-16
View user profile

Re: Using Loop Control Variable

on Thu Aug 16, 2018 10:45 am
Jericho wrote:
daniella wrote:
Rhei wrote:thank you po maam sa matyagang pagtuturo sa amin! Very Happy

hahaha kailangan para pumasa joke. Smile) love ko kayo kahit di niyo ko love sad Wink Sad Very Happy
Love ka namen maam kahit na ginugulo ka namen sa lesson mo po. Laughing Laughing Laughing

SIGE! Very Happy hahaha

Ano mas prefer ng ibang programmers, ung gumamit ng array o hindi?
avatar
Newbie
Posts : 3
Join date : 2018-08-16
View user profile

Re: Using Loop Control Variable

on Thu Aug 16, 2018 10:46 am
rsls wrote:
Jericho wrote:
daniella wrote:
Rhei wrote:thank you po maam sa matyagang pagtuturo sa amin! Very Happy

hahaha kailangan para pumasa joke. Smile) love ko kayo kahit di niyo ko love sad Wink Sad Very Happy
Love ka namen maam kahit na ginugulo ka namen sa lesson mo po. Laughing Laughing Laughing

SIGE! Very Happy hahaha

Ano mas prefer ng ibang programmers, ung gumamit ng array o hindi?

Kung Data Files kasi ang pag-uusapan Brech, Mas Gusto nila ang Arrays kasi mas Firm ang List ng Informations
avatar
Guru
Posts : 10
Join date : 2018-08-16
View user profile

Re: Using Loop Control Variable

on Thu Aug 16, 2018 10:46 am
Luwiezzzz wrote:Thank you for creating this, I finally know how to use the loop control properly

Thanks po maam. mas naiintindihan ko na lahat .. sana magawa ko ng tama yun sa actual
avatar
Guru
Posts : 10
Join date : 2018-08-16
View user profile

Re: Using Loop Control Variable

on Thu Aug 16, 2018 10:49 am
Sean wrote:
Emie Laide wrote:Pwede po bang sabay na gamitin ang counter at sentinel?
sa pagkakaintindi ko or opinyon ko lang 😂 hindi ata pwede na sabay gamitin kasi yung Counter loop is para maka create ng definite loop while yung isa using sentinel value is para maka create ng indefinite loop . Bale two ways siya on how to control a loop's repetitions .

Sent from Topic'it App
oo hindi pwede kasi nga yung counter loop ay para makacreate ng definite loop . at yung sentinel para makacreate ng indefinite loop.
avatar
Guru
Posts : 10
Join date : 2018-08-16
View user profile

Re: Using Loop Control Variable

on Thu Aug 16, 2018 10:50 am
maam ang loop po ba ay pwede hindi na huminto ? parang poreber ganun wala ng katapusan ?
avatar
Guru
Posts : 10
Join date : 2018-08-16
View user profile

Re: Using Loop Control Variable

on Thu Aug 16, 2018 10:51 am
airojames wrote:Yes may panibagong topic

Salamat po mam sa panibagong topic

sana talaga magamit ko to . sa actual salamat maam sa topic na to
avatar
Guru
Posts : 10
Join date : 2018-08-16
View user profile

Re: Using Loop Control Variable

on Thu Aug 16, 2018 10:53 am
maam what if gumawa kami ng looping na add lang ng add ng 1 .. yung space po ba ng program na yun ay lalaki ?
avatar
Newbie
Posts : 3
Join date : 2018-08-16
View user profile

Re: Using Loop Control Variable

on Thu Aug 16, 2018 10:57 am
Bermon O. Ferreras Jr wrote:maam what if gumawa kami ng looping na add lang ng add ng 1 .. yung space po ba ng program na yun ay lalaki ?

Hindi siguro pre. Counter lang naman ang nag-aadd ng nag a add, hindi naman ata kakain ng malaking space.
avatar
Guru
Posts : 12
Join date : 2018-08-03
View user profile

Re: Using Loop Control Variable

on Fri Aug 17, 2018 7:08 pm
Bermon O. Ferreras Jr wrote:
Sean wrote:
Emie Laide wrote:Pwede po bang sabay na gamitin ang counter at sentinel?
sa pagkakaintindi ko or opinyon ko lang 😂 hindi ata pwede na sabay gamitin kasi yung Counter loop is para maka create ng definite loop while yung isa using sentinel value is para maka create ng indefinite loop . Bale two ways siya on how to control a loop's repetitions .

oo hindi pwede kasi nga yung counter loop ay para makacreate ng definite loop . at yung sentinel para makacreate ng indefinite loop.


Ahahaha piliin mo lang yung mas kailangan mo 😂

Sent from Topic'it App
avatar
Guru
Posts : 12
Join date : 2018-08-03
View user profile

Re: Using Loop Control Variable

on Fri Aug 17, 2018 7:10 pm
Bermon O. Ferreras Jr wrote:maam ang loop po ba ay pwede hindi na huminto ? parang poreber ganun wala ng katapusan ?


Gamit ka sentinel para indefinite na😂

Sent from Topic'it App
Guru
Posts : 10
Join date : 2018-07-31
View user profile

Re: Using Loop Control Variable

on Fri Aug 17, 2018 7:13 pm
Asdfghjkl wrote:
Bermon O. Ferreras Jr wrote:maam ang loop po ba ay pwede hindi na huminto ? parang poreber ganun wala ng katapusan ?


Gamit ka sentinel para indefinite na😂

Sent from Topic'it App

Parang yung sa time pwedeng dmo tapusin kasi tuly tuloy lng nmn ung oras. Depende nlng kung timer ginawa mo Wink
Guru
Posts : 10
Join date : 2018-07-31
View user profile

Re: Using Loop Control Variable

on Fri Aug 17, 2018 7:18 pm
Vann Lewis wrote:
Bermon O. Ferreras Jr wrote:maam what if gumawa kami ng looping na add lang ng add ng 1 .. yung space po ba ng program na yun ay lalaki ?

Hindi siguro pre. Counter naman ang nag-aadd ng nag a add, hindi naman ata kakain ng malaking space.

Sa tingin ko tama si vann Smile
avatar
Guru
Posts : 12
Join date : 2018-08-03
View user profile

Re: Using Loop Control Variable

on Fri Aug 17, 2018 7:37 pm
Tanong lang po Kasi po nhng nakaraang quiz diba po analog clock yun naisip ko lang po if timer po yung gagawan nun pano po yung magiging flow kasi po reverse po yun diba?

Sent from Topic'it App
avatar
Guru
Posts : 12
Join date : 2018-08-03
View user profile

Re: Using Loop Control Variable

on Fri Aug 17, 2018 7:40 pm
Emie Laide wrote:
Asdfghjkl wrote:
Bermon O. Ferreras Jr wrote:maam ang loop po ba ay pwede hindi na huminto ? parang poreber ganun wala ng katapusan ?


Gamit ka sentinel para indefinite na😂


Parang yung sa time pwedeng dmo tapusin kasi tuly tuloy lng nmn ung oras. Depende nlng kung timer ginawa mo [smiley]https://illiweb.com/fa/i/smiles/icon_wink.gif[/smiley]

Alam ko ang timer reverse yun ehh

Sent from Topic'it App
Guru
Posts : 10
Join date : 2018-07-31
View user profile

Re: Using Loop Control Variable

on Fri Aug 17, 2018 7:50 pm
Asdfghjkl wrote:
Emie Laide wrote:
Asdfghjkl wrote:
Bermon O. Ferreras Jr wrote:maam ang loop po ba ay pwede hindi na huminto ? parang poreber ganun wala ng katapusan ?


Gamit ka sentinel para indefinite na😂


Parang yung sa time pwedeng dmo tapusin kasi tuly tuloy lng nmn ung oras. Depende nlng kung timer ginawa mo [smiley]https://illiweb.com/fa/i/smiles/icon_wink.gif[/smiley]

Alam ko ang timer reverse yun ehh

Sent from Topic'it App

verywrong. Depende pla kung stopwatch ginawa mo.
Guru
Posts : 10
Join date : 2018-07-31
View user profile

Re: Using Loop Control Variable

on Fri Aug 17, 2018 7:51 pm
Asdfghjkl wrote:Tanong lang po Kasi po nhng nakaraang quiz diba po analog clock yun naisip ko lang po if timer po yung gagawan nun pano po yung magiging flow kasi po reverse po yun diba?

Sent from Topic'it App

Gagawin mo lng -1 kasi reverse
avatar
Guru
Posts : 13
Join date : 2018-08-16
View user profile

Re: Using Loop Control Variable

on Fri Aug 17, 2018 10:41 pm
mam pag gumawa po ba ng looping, endless po ba yung pag loloop nya?
Guru
Posts : 10
Join date : 2018-07-31
View user profile

Re: Using Loop Control Variable

on Sat Aug 18, 2018 12:02 pm
rapal wrote:mam pag gumawa po ba ng looping, endless po ba yung pag loloop nya?
Depende na ata yun . Kaya may sentinel value at counter Smile
avatar
Guru
Posts : 15
Join date : 2018-08-19
View user profile

Re: Using Loop Control Variable

on Sun Aug 19, 2018 12:50 pm
Bermon O. Ferreras Jr wrote:
Sean wrote:
Emie Laide wrote:Pwede po bang sabay na gamitin ang counter at sentinel?
sa pagkakaintindi ko or opinyon ko lang 😂 hindi ata pwede na sabay gamitin kasi yung Counter loop is para maka create ng definite loop while yung isa using sentinel value is para maka create ng indefinite loop . Bale two ways siya on how to control a loop's repetitions .

oo hindi pwede kasi nga yung counter loop ay para makacreate ng definite loop . at yung sentinel para makacreate ng indefinite loop.
sa pag kakaalam ko hinde ata pwedeng pagsabayin gamitin yung counter at sentinel

Sent from Topic'it App
Sponsored content

Re: Using Loop Control Variable

Back to top
Permissions in this forum:
You cannot reply to topics in this forum