Just a tip for anyone who may be confused because this confused me for a long time and it is not mentioned much in many tutorials for nested for loops. Remember that the initial outer for loop variable maintains it's incremented variable value. The nested inner for loop resets back to the initial variable value each time it is entered. This is to do with scope. I had a hard time figuring this out because I would initialize two variables in the same place but run into this problem still. Hope it helps!
The outer loop is only used for counting the number of times the inner loop should print the print function, after every print statement in the inner loop, the program exits the inner loop and go back to the outer loop. Then the outer for loop gets initialized to i=1, now the program enters the inner loop, this time the inner for loop gets initialized to 1 instead of 0. So 1 will be printed and then due to k-- decrement, the next number will be 0, and also due to the print("/n"); at the end of inner for loop, the output will go to a new line in output console. Ask me in comments if you have any doubts, I was confused as well at first as it looks confusing.
thanks! you helped me understand this one better. going step by step through the loops, and writing down every step on a paper helps understand what this 2 loops did. :)
Caleb....I must confess this is my nightmare as a beginner (nested loops - for, while or do while). So far u have helped me cement understanding of the preceding concepts. Please help with videos that carefully explain the rational for for loops, the concepts and probably numerous use cases just like in the previous lectures. This aspect so confusing man. Thanks
tqsm for the tutorial, though im curious whats the name for ur outro😅, ik its "rx savagez-wolves" but theres weird noise every few seconds + ur vid is 2 yrs older than his
@@codebreakthrough Thank you Caleb. I have the printf in the nested loop. But I just don't get how the computer knows to print 0, 10, 210.... It has printf("%d ",k); so I assumed (making a butt of myself) that it will only print k's value. Im watching all of the videos in your C tutorial and I have to say they are awesome! Thank you so much!!!!!!
I know i am 2 years late but What do i put if i want to place number like 1,2,3,4,5,6,7,8,9,10 1,2,3,4,5,6,7,8,9 1,2,3,4,5,6,7,8 So on I'm a beginner at coding btw And i need your help
actually I sorted it out, if anyone is curious about this question and wants the solution this is how I did it int main() { for (int i = 10; i >= 1; i--) {
@@Blank-Kong2RuYe Thank you! I think you are right. It's wolves' from rx savagez. I looked it up on youtube and it was this song. And you are also right about that noise every few seconds ....like a 'ping' that you hear on airlines when they want to make an announcement.
One question.. What if we want to count a particular number in for loop... Ex. I want to count the number of 7’s in that whole loop... how do i do that..?!?
#include /* ---# --## -### #### */ int main() { int height; printf("Enter the height of the triangle : "); scanf("%d", &height); for(int i = 1; i i; j--){ printf(" "); } for(int k = 0; k < i; k++){ printf("#"); } printf(" "); } return 0; } like this??
bro...free videos, none of which are over 8 to 9 minutes long. If you don't want pizza or taco talk, pay for a course. If I'm not mistaken the forward arrow key skips ahead about 15 seconds or so as well.
Just a tip for anyone who may be confused because this confused me for a long time and it is not mentioned much in many tutorials for nested for loops.
Remember that the initial outer for loop variable maintains it's incremented variable value. The nested inner for loop resets back to the initial variable value each time it is entered. This is to do with scope.
I had a hard time figuring this out because I would initialize two variables in the same place but run into this problem still. Hope it helps!
ohmygod thank you so much
Did confuse me at first. Great Point !!!!
Great comment I think this has helped me figure it out better. Thanks
Thank You So Much, Very Informative......!
oooo gooooddd never been full of gratitude i send you all the love in my heart
The outer loop is only used for counting the number of times the inner loop should print the print function, after every print statement in the inner loop, the program exits the inner loop and go back to the outer loop. Then the outer for loop gets initialized to i=1, now the program enters the inner loop, this time the inner for loop gets initialized to 1 instead of 0. So 1 will be printed and then due to k-- decrement, the next number will be 0, and also due to the print("/n"); at the end of inner for loop, the output will go to a new line in output console. Ask me in comments if you have any doubts, I was confused as well at first as it looks confusing.
I am still confused, like please help i am struggling since 2 days, but still not clear about it
@@kewrie1630 ua-cam.com/video/qUPXsPtWGoY/v-deo.html
Watch this and if you still don't get it, let me know
thanks! you helped me understand this one better. going step by step through the loops, and writing down every step on a paper helps understand what this 2 loops did. :)
Nested? More like bested...by no other UA-cam C tutorial! Thanks again for making all of this wonderful content.
Caleb....I must confess this is my nightmare as a beginner (nested loops - for, while or do while). So far u have helped me cement understanding of the preceding concepts. Please help with videos that carefully explain the rational for for loops, the concepts and probably numerous use cases just like in the previous lectures. This aspect so confusing man. Thanks
Caleb, you gotta add the last 30 vids of this series to the C tutorial playlist. It takes maybe 5-10 minutes at most.
Your explanations and videos for C Programming are incredibly helpful. Thank you for sharing this information and your organization!!!
I really enjoy how he started talking about food at the middle of the code.
could not find anyone else doing an example of this one. TY
You’ve saved my life. I’ve been eating more pizza since this video and I’m now happier having had more pizza.
This is amazing. Thanks for explaining in such an easy way
Ok now im actually lost
On what specifically? I might be able to help and explain.
you definitely deserve more and more, thank you sooooooooooooo much
What I learned from this video? Pizza > Tacos. Thank you for the clarification ;)
Glad I made that crystal clear!!
Thank you so much, this tutorial is carrying me through university!
thank you man ,i am in college and this helped me a lot!
nested loops are just cogs. As one turns, so does the other.
pizza not better than tacos
tqsm for the tutorial, though im curious whats the name for ur outro😅, ik its "rx savagez-wolves" but theres weird noise every few seconds + ur vid is 2 yrs older than his
2:35 ayo, idk if you're talking about taco bell, but mexican tacos are better than pizza, no discussions
02:23 Isn't by convention the inner loop letter j? It is the next letter after i.
J or k
But I guess that would make sense 🙂
Maybe k for a loop in a loop in a loop?
Pizza > tacos
Which software is this ?
why do you print %d? what does that do?
its float data type similarly to we use %s in string, we use %d or %f for double or float
Thanx, u r so good at explanation
pizza is not better than tacos lol
I have 3 for loops that I should merge to two for loops can someone help me?
If you reply to this comment with your code, I can take a look and offer some suggestions.
You are the best
Can you do one for c++
you were in my dream last night caleb, at a waterfall
hot
It did compiled?
I'm confused. It looks like it is only printing k, how does it know to print i too? :(
Make sure you have a print in the inner loop 😊
@@codebreakthrough Thank you Caleb. I have the printf in the nested loop. But I just don't get how the computer knows to print 0, 10, 210.... It has printf("%d ",k); so I assumed (making a butt of myself) that it will only print k's value. Im watching all of the videos in your C tutorial and I have to say they are awesome! Thank you so much!!!!!!
Tacos over pizza!
go ahead bro really you are amazing
I know i am 2 years late but
What do i put if i want to place number like
1,2,3,4,5,6,7,8,9,10
1,2,3,4,5,6,7,8,9
1,2,3,4,5,6,7,8
So on
I'm a beginner at coding btw
And i need your help
#include
int main()
{
for (int i = 10; i>0; i--)
{ printf ("
");
for (int j = 1; j
Did you ever get an answer to this question? I'm curious how to do that now
actually I sorted it out, if anyone is curious about this question and wants the solution this is how I did it
int main()
{
for (int i = 10; i >= 1; i--)
{
for(int k = 1; k
caleb I love you but tacos >= pizza;
i think tacos == pizza; XD
i mean, you make a lot of unnecessary side comments but great tutorial nonetheless!
Am I the only one that still doesn't get it? Lol
The Best
What is the name of the outtro music at 5:50?
i wanna know too ;-; , it may be "wolves' from rx savagez but theres always a weird noise every few seconds
@@Blank-Kong2RuYe Thank you! I think you are right. It's wolves' from rx savagez. I looked it up on youtube and it was this song. And you are also right about that noise every few seconds ....like a 'ping' that you hear on airlines when they want to make an announcement.
@@okkami676 glad u found it! though I doubt rx savagez is the original author since he posted 2 yrs after this video
OMGGGGG THANK YOU.... SPACE IS IMPORTANT TOO! HAHA
One question..
What if we want to count a particular number in for loop... Ex. I want to count the number of 7’s in that whole loop... how do i do that..?!?
if (i == 7)
{
numOf7++;
}
if (j == 7)
{
numOf7++;
}
tacos
I think this video main topic is how pizza is better than tacos (҂⌣̀_⌣́)
i think tacos == pizza; XD
I have a question
How do I create this??
. . . #
. . ##
. ###
####
I tried so hard but I can't figure it out can someone help me PLEASE 😭
Jojo X now i where your stidying coz this is actually home work😂😂😂😂😂😂😂😂
@@kingnicky2568 it was the harvard edx cs50 course lmao and I figured it out by now btw 😍😍😍
Jojo X i am a programer too mind if we connect.? I have home work and still cant figure it out... if so please text me “kingnickyjr999@gmail.com”
#include
/*
---#
--##
-###
####
*/
int main()
{
int height;
printf("Enter the height of the triangle : ");
scanf("%d", &height);
for(int i = 1; i i; j--){
printf(" ");
}
for(int k = 0; k < i; k++){
printf("#");
}
printf("
");
}
return 0;
}
like this??
@@daverussell4052 lol omg thanks 😂😅🥺😍
*
***
*****
*******
*********
bro when you make a video cut to the chase and stop talking about pizza and tacos
bro...free videos, none of which are over 8 to 9 minutes long. If you don't want pizza or taco talk, pay for a course. If I'm not mistaken the forward arrow key skips ahead about 15 seconds or so as well.
sweeeeeeeeeet