The FOR loop
+22
Bermon O. Ferreras Jr
Ferre
Rfrancis03
RicManipon
Jung Kook
Lawrence
Pox
judedominguiano
iramae
Louise Sebastiane Yagi
justjoking10
ilovebts
myramonique
Emie Laide
Sean
michael jhon
airojames
ALEXIS_GAMING
Luwiezzzz
James Navarro
Rhei
daniella
26 posters
The FOR loop
Fri Jul 27, 2018 6:45 pm
In addition to the while statement, most computer languages support a for statement. You usually use the for statement, or for loop, with definite loops—those that will loop a specific number of times when you know exactly how many times the loop will repeat.
for Statement Pseudocode Standards
The amount by which a for loop control variable changes is often called a step value. The step value can be any number and can be either positive or negative; that is, it can increment or decrement.
A for loop can express the same logic as a while statement, but in a more compact form. You never are required to use a for statement for any loop; a while loop can always be used instead. For example, to display Hello four times, you can write either of the sets of statements in Figure BELOW.
Comparable while and for statements that each output Hello four times
The code segments, each accomplish the same tasks:
1.The variable count is initialized to 0.
2. The count variable is compared to the limit value 3; while count is less than or equal to 3, the loop body executes.
3. As the last statement in the loop execution, the value of count increases by 1. After the increase, the comparison to the limit value is made again.
A while loop can always be used instead of a for loop, but when a loop’s execution is based
on a loop control variable progressing from a known starting value to a known ending value in
equal steps, the for loop provides a convenient shorthand.
for Statement Pseudocode Standards
The amount by which a for loop control variable changes is often called a step value. The step value can be any number and can be either positive or negative; that is, it can increment or decrement.
A for loop can express the same logic as a while statement, but in a more compact form. You never are required to use a for statement for any loop; a while loop can always be used instead. For example, to display Hello four times, you can write either of the sets of statements in Figure BELOW.
Comparable while and for statements that each output Hello four times
The code segments, each accomplish the same tasks:
1.The variable count is initialized to 0.
2. The count variable is compared to the limit value 3; while count is less than or equal to 3, the loop body executes.
3. As the last statement in the loop execution, the value of count increases by 1. After the increase, the comparison to the limit value is made again.
A while loop can always be used instead of a for loop, but when a loop’s execution is based
on a loop control variable progressing from a known starting value to a known ending value in
equal steps, the for loop provides a convenient shorthand.
- RheiGuru
- Posts : 11
Join date : 2018-07-28
Re: The FOR loop
Sat Jul 28, 2018 4:13 pm
Maam Ano po ang pinagkaiba sa paggamit ng For, If and While ?
- SeanGuru
- Posts : 15
Join date : 2018-07-27
Re: The FOR loop
Sat Jul 28, 2018 7:30 pm
As long sa Structured tingnan yung flowchart . Possible na pwede yung For Loop inside a while loop or vice versa @yagi tapos sa pseudo code naman . I think makikita mo naman agad if may For loop sa loob ng while loop kasi naka indent siya . @brix . Yun lang sa opinyon ko hehe
Sent from Topic'it App
Sent from Topic'it App
- James NavarroGuru
- Posts : 12
Join date : 2018-07-31
Re: The FOR loop
Tue Jul 31, 2018 5:12 pm
Maam ang dami ko pong natutunan sa forum nyo, sayang lang at huli na para itama ko yung sinagot ko dun sa quiz hehehe
Sent from Topic'it App
Sent from Topic'it App
- Luwiezzzz
- Posts : 2
Join date : 2018-07-31
Re: The FOR loop
Tue Jul 31, 2018 6:52 pm
This forum helped me a lot understanding the FOR loop, thank you for creating this
- airojamesGuru
- Posts : 11
Join date : 2018-07-31
Re: The FOR loop
Tue Jul 31, 2018 7:46 pm
Kaya nga po example po medyo naguguluhan po kasi ako sa for loop
- James NavarroGuru
- Posts : 12
Join date : 2018-07-31
Re: The FOR loop
Tue Jul 31, 2018 7:48 pm
Sa next discussion yan maraming example si maam Hahaha
Sent from Topic'it App
Sent from Topic'it App
- airojamesGuru
- Posts : 11
Join date : 2018-07-31
Re: The FOR loop
Tue Jul 31, 2018 7:51 pm
Yung for loop po ba isang beses lang pwede gamitin sa isang program? Wala po kasing sample nya
- ALEXIS_GAMINGGuru
- Posts : 10
Join date : 2018-07-31
Re: The FOR loop
Tue Jul 31, 2018 7:54 pm
Ma'am pwede pa po ba kayo magbigay ng ibang examples po? Medyo nagugulumihanan po ako ee
- James NavarroGuru
- Posts : 12
Join date : 2018-07-31
Re: The FOR loop
Tue Jul 31, 2018 7:59 pm
Sana marami din ako knowledge kagaya ng mga knowledge nyo sa coding at stuff mga cm at maam hehehe, di ko magets ibang mga tanong dito e whahahaha.. Pero laking tulong po nitong forum
Sent from Topic'it App
Sent from Topic'it App
- airojamesGuru
- Posts : 11
Join date : 2018-07-31
Re: The FOR loop
Tue Jul 31, 2018 8:05 pm
Mam pwede po bang gawing sentinel value yung module?
Sa module ko po kasi nandoon po yung list ng mga product kumbaga data base. Kaya gagawin ko po syang sentinel value if ever wala po sya doon sa list magtatype po ulit ng panibago pwede po ba? Kung hindi ano po suggestion nyo?
Natanong lang sensya na po wala pang alam sa mga ganyan
Sa module ko po kasi nandoon po yung list ng mga product kumbaga data base. Kaya gagawin ko po syang sentinel value if ever wala po sya doon sa list magtatype po ulit ng panibago pwede po ba? Kung hindi ano po suggestion nyo?
Natanong lang sensya na po wala pang alam sa mga ganyan
- airojamesGuru
- Posts : 11
Join date : 2018-07-31
Re: The FOR loop
Tue Jul 31, 2018 8:06 pm
Mam kapag while loop po ba laging (<>)not equal gagamitin?
- airojamesGuru
- Posts : 11
Join date : 2018-07-31
Re: The FOR loop
Tue Jul 31, 2018 8:08 pm
Kapag for loop naman po may required comparison po ba sya or wala?
- airojamesGuru
- Posts : 11
Join date : 2018-07-31
Re: The FOR loop
Tue Jul 31, 2018 8:09 pm
Mam sa ginawa po naming flowchart sa time
Paano po mapapabalik sa input na equals to 0 para maging 00 po yung seconds nya at hindi maging 61,62....
Paano po mapapabalik sa input na equals to 0 para maging 00 po yung seconds nya at hindi maging 61,62....
- airojamesGuru
- Posts : 11
Join date : 2018-07-31
Re: The FOR loop
Tue Jul 31, 2018 8:36 pm
Mam kung yung while loop is may loop control variable sa for loop po meron din po ba?
- SeanGuru
- Posts : 15
Join date : 2018-07-27
Re: The FOR loop
Tue Jul 31, 2018 9:25 pm
@airojames . Regarding dun sa tanong mo (Comment #16) . Sa pagkaka intindi ko . Yung While Loop at For Loop . Same sila na may Control Variable
Sent from Topic'it App
Sent from Topic'it App
- michael jhonModerator
- Posts : 6
Join date : 2018-07-31
Re: The FOR loop
Tue Jul 31, 2018 9:31 pm
mam ano po yung step value siya ba yung nagse2t kung magiincrease yung value at magde2crease?
- SeanGuru
- Posts : 15
Join date : 2018-07-27
Re: The FOR loop
Tue Jul 31, 2018 9:34 pm
Siguro yung pwede ka maglagay ng process after ng loop sa sec na pwede makakapag balik sa zero yung sec. example kapag naka 60 na sec kana after nun diretso na siya sa ginawa mong proces na yung min. + 1 tapos yung 60 - 60 para 0 na ulit yung sec.airojames wrote:Mam sa ginawa po naming flowchart sa time
Paano po mapapabalik sa input na equals to 0 para maging 00 po yung seconds nya at hindi maging 61,62....
Sent from Topic'it App
- SeanGuru
- Posts : 15
Join date : 2018-07-27
Re: The FOR loop
Tue Jul 31, 2018 9:46 pm
Pwede naman siguro more than one kasi parehas sa while loop pwede mo ka gumamit ng while loop ng more than one .ganun din siguro sa for loop kasi same logic lang naman sila ng statement tsaka if nalilito padin sa for loop di naman siya required na siya talaga yung gagamitin lang . pwede naman na while loop nalang gamitin kasi mas madali siya intindihin at gawinairojames wrote:Yung for loop po ba isang beses lang pwede gamitin sa isang program? Wala po kasing sample nya
Sent from Topic'it App
- SeanGuru
- Posts : 15
Join date : 2018-07-27
Re: The FOR loop
Tue Jul 31, 2018 9:51 pm
ako din pre eh pero mas maganda padin if while loop nalang gamitin pre . mas madali intindihin tsaka gawinALEXIS_GAMING wrote:Ma'am pwede pa po ba kayo magbigay ng ibang examples po? Medyo nagugulumihanan po ako ee
Sent from Topic'it App
- SeanGuru
- Posts : 15
Join date : 2018-07-27
Re: The FOR loop
Tue Jul 31, 2018 9:53 pm
*while statement ratherSean wrote:ako din pre eh pero mas maganda padin if while loop nalang gamitin pre . mas madali intindihin tsaka gawinALEXIS_GAMING wrote:Ma'am pwede pa po ba kayo magbigay ng ibang examples po? Medyo nagugulumihanan po ako ee
Sent from Topic'it App
- SeanGuru
- Posts : 15
Join date : 2018-07-27
Re: The FOR loop
Tue Jul 31, 2018 10:07 pm
Base sa tanong ni @Rheign . Sa pagkaka intindi ko yung if statement it's either mameet niya yung condition or hindi, magtutuloy lang siya pero yung while statement at for statement naman if hindi niya mameet yung condition uulit lang siya or mag lo.loop siya hanggang sa ma meet na niya yung condition . sana tama haha
Sent from Topic'it App
Sent from Topic'it App
- SeanGuru
- Posts : 15
Join date : 2018-07-27
Re: The FOR loop
Tue Jul 31, 2018 10:10 pm
Oo pre siya yung mag se.set kung either magiincrease or magde.decrease yung value na gusto mo ma meet sa condition mo . Sa tingin ko ...michael jhon wrote:mam ano po yung step value siya ba yung nagse2t kung magiincrease yung value at magde2crease?
Sent from Topic'it App
- Emie LaideGuru
- Posts : 10
Join date : 2018-07-31
Re: The FOR loop
Tue Jul 31, 2018 10:59 pm
Sa pagkakaintindi ko ang for at while parehas lng nmn ng gamit. Pero kung gusto mong mas maging maikli yung pseudo mo gamit ka ng for.
- SeanGuru
- Posts : 15
Join date : 2018-07-27
Re: The FOR loop
Tue Jul 31, 2018 11:02 pm
Lodi HAHAHA .Emie Laide wrote:Sa pagkakaintindi ko ang for at while parehas lng nmn ng gamit. Pero kung gusto mong mas maging maikli yung pseudo mo gamit ka ng for.
Sent from Topic'it App
Permissions in this forum:
You cannot reply to topics in this forum
|
|