OMG you explained this so well! Thank you! I couldn’t wrap my head around WHY is was doing that. I knew how to control it by memory alone but not by understanding. 🙏
The first "i" is equal to 0 (i = 0). But, before it gets printed it goes through the equation of i = i + 1 so the first i that gets printed is 1. Now at the i = 8 mark it goes through the equation i = i+1 (before getting printed) and gets printed out as 9. Then 9 != 10 goes through and gets printed as (the last number) 10. Then when 10 goes through it becomes 10 != 10 WHICH IS FALSE so ends the while loop. as printed (1,2,3,4,5,6,7,8,9,10). D - "Print out the numbers from 1 to 10"
Ok so I just got started in coding. My problem is i don’t understand where to execute my code. Is it supposed to work in the console? I’m using google chrome and I could really use someone’s help.
heloo any one can help me to solve this program Write a C++ programme that reads a sequence of integers terminated by zero value then finds the percentage of the negative numbers and the percentage of the positive number in the sequence. The programme output is as shown: : Enter a sequence of in integers terminated by zero 6 -7 -8 10 -12 14 15 2 -6 the percentage of negative numbers is 44.4 the percentage of positive numbers is 55.6
I was given an example: n = 5 while n > 0: n = n - 1 print(n) 4 3 2 1 0 From this result: it is clear that the layout in the body is wrong; the 'print()' statement should go first.
It will produce error since the test expression is not true. So the block will also not be executed. Numbers are only incrementing if the test expression is true only.
Actual answer is 1-10: Option 4. The reason it stops at 10 instead of 9 now is because it's checking... is i = 10 yet? once it says YES then we exit the loop. The loop terminates RIGHT there because it reached its goal which is 10. Only part i don't get is why it does not start at 0 to 10... why 1.
@@stannisbarracuda5693 exactly that's what I was thinking... != In Python to the best of my knowledge is does NOT equal....so should have exited.... However my Python emulator is showing 10 too.
Is it 3) 1 to 9? Cause it'll only print after the initial value of i (0) is added to the operation *i = i + 1* And it also satisfies the condition that i ≠ 10
Remember that when the final loop begins when i=9 the condition is met (i is less than 10). Then the i is changed to 10 before i is printed, so this program would print 1 - 10.
@@benzox9940 its all about the sequence, having the i + 1 before the print command added 1 to the i value prior to it printing, so it started printing numbers starting with 1 then restarted the while loop and printed the numbers 1 to 10. If the i + 1 was after the print command it would have printed the number 0 then added 1 to i and restarted the while loop and printed all numbers from 0-10.
i = 0 while i is not equal to 10 i = i +1 print i is i not equal to 10? ( i = 0) Yes, the program ends until it keeps adding the value 1 to the variable i until it defies the while condition, repeating the while loop 9 times until "not equal to 10" becomes "equal to 10". Thank me later
Word I noticed that but I'm just getting into it so I think it's still helpful. I would say this is an example of debugging because how he wrote it the program would print before any addition
@@phuturephunk because it was asked to print all numpers that are less than ten , this question is diffrant , it askes for all numpers that does not equal ten ( 1 2 3 4 5 6 7 8 9 _ 11 12 13 ....)
Great video but your hands distract from everything. We don’t need to see your hand writing it, we need to see the code. Also, use white font on a black background like anyone who stares at a screen for 8+ hours a day does, can’t watch this after a day of work + school.
this is the best explanation ever of while loop !! thank you sir !
I swear this is the best explanation I have seen for a while loop I really understand it so now I can write a code with this understanding.
I WAS STUCK ON THIS FOREVER!!! THANK YOU!!!
OMG you explained this so well! Thank you! I couldn’t wrap my head around WHY is was doing that. I knew how to control it by memory alone but not by understanding. 🙏
one of the best explanations ever for while loop 🔁 ❤️ thanks
This is so much better than the way my instructor told us!
The first "i" is equal to 0 (i = 0). But, before it gets printed it goes through the equation of i = i + 1 so the first i that gets printed is 1.
Now at the i = 8 mark it goes through the equation i = i+1 (before getting printed) and gets printed out as 9. Then 9 != 10 goes through and gets printed as (the last number) 10. Then when 10 goes through it becomes 10 != 10 WHICH IS FALSE so ends the while loop.
as printed (1,2,3,4,5,6,7,8,9,10). D - "Print out the numbers from 1 to 10"
Very detailed explanation
This is called a mind opening explanation.🌼
wow
Wow thanks for the in-depth explanation
the value prints 1-10 if we put i=i+1 about print, can u explain why?
what pen did you use? and where you wrote it?
10/10
Really nice explained👌🏽
Thanks a lot
i love you so much you saved me 100%. thanks a lot fr. youre a real one
Excellent explaination keep it up
came here for loops brother, was bamboozled
i keep getting "invalid syntax"
and the 3 keeps getting highlighted in the top "python 3.9.0"
Absolutely beautiful
Thanks for comparing While and if.......
can we use colon instead of parenthesis in WHILE ???
Semicolon after printf() is missing
AYBIN. V. K it will always depend on what programming language you are using
EDIT:
as I can see, his code sample is based on Python
We want more videos of this loop programs
Simplest way.... Thank you so much
Great video!
very good explanation
A perfect explanation
it does print 1 to 9 doesn't it ?
Print from 1 to 10 values and comes out of the loop
well done! thank you!
Ok so I just got started in coding. My problem is i don’t understand where to execute my code. Is it supposed to work in the console? I’m using google chrome and I could really use someone’s help.
you can watch this video.. czcams.com/video/0XamI1W-wzE/video.html
THANK YOU SO MUCH BRO
What language is this in??
Thank you sir!!!
heloo any one can help me to solve this program
Write a C++ programme that reads a sequence of integers terminated by zero value then finds the percentage of the negative numbers and the percentage of the positive number in the sequence. The programme output is as shown: :
Enter a sequence of in integers terminated by zero
6 -7 -8 10 -12 14 15 2 -6
the percentage of negative numbers is 44.4
the percentage of positive numbers is 55.6
let a = "Hello, ";
let b = "World";
let c = a + b
console.log(c);
thank me later this is the best i could do.
love it
I was given an example:
n = 5
while n > 0:
n = n - 1
print(n)
4
3
2
1
0
From this result: it is clear that the layout in the body is wrong; the 'print()' statement should go first.
i used Small Basic program and my answer was : {print out the numbers from 0 to 9}.
Option d is correct
produces an error, there is no parentheses around the print statement
Yeah
It will produce error since the test expression is not true. So the block will also not be executed. Numbers are only incrementing if the test expression is true only.
so cool
thank you
what happens if you remove the condition of i= i +1
infintiiy loop will go on and prints 0 for infintiiy
@هههههههههههههههه مصرى
Actual answer is 1-10: Option 4. The reason it stops at 10 instead of 9 now is because it's checking... is i = 10 yet? once it says YES then we exit the loop. The loop terminates RIGHT there because it reached its goal which is 10. Only part i don't get is why it does not start at 0 to 10... why 1.
It starts at 0, but then in the block i=0+1, so i has a new value of 1, and finally print i that is equal to 1.
i = 0
while(i != 10):
i = i + 1
print("i =", i)
print("Exit Loop")
Phython
it writes from zero and ends at 9 it would write 10 if the parameter was
@@stannisbarracuda5693 exactly that's what I was thinking... != In Python to the best of my knowledge is does NOT equal....so should have exited.... However my Python emulator is showing 10 too.
Scratch that....just gave this more thought think a little longer...
there is no semilcolon in while( parenthesis)😐😐😐😐
diwakar bangera there is in Python programming language
Is it
3) 1 to 9?
Cause it'll only print after the initial value of i (0) is added to the operation *i = i + 1*
And it also satisfies the condition that i ≠ 10
Remember that when the final loop begins when i=9 the condition is met (i is less than 10). Then the i is changed to 10 before i is printed, so this program would print 1 - 10.
is the answer the third option?
H J it will print numbers 1-10 then exit the loop. Nine is not equivalent to ten so it will go through the loop one more time
X=1
Whilex
The answer is for your quiz =
1
2
3
4
5
6
7
8
9
10
Thank you from Sri Lanka❤❤❤
it is an error right?
option d
Ok so who had the right answer? I felt like it was 1 to 10
It's 0 to 9
option 2
The answer is that the program prints out the numbers from 1 to 10
Im stuck on this, Do you know why? And whats the difference when the addition follows the print?
@@benzox9940 bruh I forgot how it works, this was two years ago..
😂😂😂😂
@@benzox9940 its all about the sequence, having the i + 1 before the print command added 1 to the i value prior to it printing, so it started printing numbers starting with 1 then restarted the while loop and printed the numbers 1 to 10. If the i + 1 was after the print command it would have printed the number 0 then added 1 to i and restarted the while loop and printed all numbers from 0-10.
D - Print out the numbers from 1 to 10
i = 0
while i is not equal to 10
i = i +1
print i
is i not equal to 10? ( i = 0)
Yes, the program ends until it keeps adding the value 1 to the variable i until it defies the while condition, repeating the while loop 9 times until "not equal to 10" becomes "equal to 10". Thank me later
true, same point noted here
Word I noticed that but I'm just getting into it so I think it's still helpful. I would say this is an example of debugging because how he wrote it the program would print before any addition
If 'i' is < 10, why would it print? While 'i' is less than 10, then the programme prints a value.
0-9 ... sorry I took so long to comment.. I'm still on dial-up
HOW?
it prints 1 to 10
Answer is 1 to 10
from 0 to 9 (b)
prints from 0-10
The answer is Run forever
Techie Tom no if the value of i is 10
So it will be 10 ! = 10 the statement will be false
Maybe runs forever
In his last example (the question at the end), it will print 1 through 10 and then exit the loop.
@@phuturephunk because it was asked to print all numpers that are less than ten , this question is diffrant , it askes for all numpers that does not equal ten ( 1 2 3 4 5 6 7 8 9 _ 11 12 13 ....)
writing with a pen ......but not really..........my heads' spinning
nb
it will run forever , because its going to print all numpers but ten , >>>>>>1 2 3 4 5 6 7 8 9 11 12 13 .....
Wrong, you misunderstand how iteration works.
doesnt it stop once y does not equal 10?
For while loop or statement click on the link czcams.com/video/D7j1YWsC45I/video.html
try i = 11 lol
Answer is 1-10: Option 4
Why would it not be B) 0-9 ?
The previous while loop went from 0 through 9.
1-10
hmmmmmm
writing technique is soo distracting...............
Try watching this video to understand loops.. czcams.com/video/0XamI1W-wzE/video.html
lol u just made it unnecessarily complecated...
For printing *"Ben"* 10 times in a loop:
10 FOR i = 1 to 10
20 PRINT "Ben"
30 NEXT i
40 END
Stupid he was teaching while loop not for loop
Great video but your hands distract from everything. We don’t need to see your hand writing it, we need to see the code. Also, use white font on a black background like anyone who stares at a screen for 8+ hours a day does, can’t watch this after a day of work + school.
very good explanation