C_35 Properties of For loop in C | C Programming Tutorials

preview_player
Показать описание
In this lecture we will discuss some properties of for loop in C.

Connect & Contact Me:

More Playlists:

#forloop #loop #cprogramming #coding #jennyslectures
Рекомендации по теме
Комментарии
Автор

This must be the mother of all lectures on for loops in C. Thank you so much for going through the detail and possible cases!!!

Maha_s
Автор

I am so happy to come across your YouTube channel. It is very helpful. you are very incredible. The way you express everything in detail and pointing out all the possibilities are fantastic. and please also keep using English in all your videos. You make all the abstract idea concrete. Thank you so much. keep up the good work.

ruthtef
Автор

15:48 there'll be no output as condition will be false, since we initialised i=1 and condition is i==10, so it will come out of the loop with even single iteration.

SN-editsu
Автор

23:35
it will print jenny for infinite times not only for 4 times since no modification is made through expression 3

kameshpatil
Автор

27:21
output= 1 7
28:28
output = 3 2 1

kameshpatil
Автор

Extremely significant lecture, thanks alot for your efforts. You are a wonderful teacher.

redrose
Автор

I am learning c++ but i always watch your videos. It helps me clear my concepts.

fatimaahmad
Автор

Thanku Mam For Data Structures Playlist . I learned basics from the starting videos of that playlist . Now I only see the title of the video and make the whole program by myself . And also all program made by me worked fine .

Thanku Mam for all your efforts .

ShubhamSingh-cdjf
Автор

Feeling good to have a teacher like you mam...thank you for hard work for us....
After having your lecture performed it myself...
for(i=1, j=0;i<5, j<=6;j++);
{
printf("%d%d\n", i, j);
i++;
}
Output will be 17...i is not updating.

for(i=1, j=0, k=3;i<=5, j<=6, k>1;i++, j++, k--);
{
printf("%d%d%d\n", i, j, k);
}
Output will be 321

pritampandit
Автор

big respect and big love from pakistan islamabad i an curently styding in the prestigeous uni of pakistan which kniwn as the top uni of pakistan FAST (NUCES), but no such teacher really big love from pakistan

harisarain
Автор

In 27:25, the forloop
for (i = 1, j = 0; i < 5, j <=6; j++);

The compiler throws an error message: left-hand operand of comma expression has no effect [-Werror=unused-value]
Meaning, the comma separator between the i < 5 and j <=6 conditional statements has no effect. Thus the code doesn't run.

PS: I am using gcc compiler.
Thanks for your videos, they've been very helpful

alarezomoosamuyi
Автор

I have passed Data structure paper by just watching ur vedios thanks mam😎

gamingislove
Автор

Thank you so much for this video ma'am. My all doubts regarding for loop got cleared. There's a request from my end ma'am. Actually in C Programming I don't know pointer and structure very well. If you make such informative video on these topics like this video, it will be really helpful ma'am. I'm genuinely following your C Programming course and eagerly waiting for upcoming stuffs and specially pointer and structure.

debadritadebnath
Автор

In 23:44 there is a mistake as we intialize the counter(i) with value 1 and in the place of condition put i<5 but HAVEN'T PUT ANY CONDITION UPDATE LIKE i++ hence the condition will always evaluates to true(1) hence int will print jenny for infinite times....

sabyasputnik_
Автор

Thank you so much, i have understood for loops better thanks to you. I tried some of the things you told us to:

For the first question in 6:55 int i will not be initialized so loop will not activate and there will be an error.
For 9:38 it will give an error since i is not initialized.
For 15:38, i==10 will give no output since condition is false from the beginning, it will go out of body of loop
For 12:30 I tried the i<=5, j<3 but it gave a relational error since apparently the comma is being used as an operator so one of the conditions is not considered but i<=5 && j<3 worked.
At minute 23:35 i tried on my IDE and it gives an infinite loop so there is a small error there.

For the assignment 1:

#include<stdio.h>

int main()
{
int i, j;

for(i = 1, j =0; i < 5, j <= 6; j++);
{
printf("%d %d\n", i, j);
i++;
}
}

; terminates the loop and the rest are considered separate statements so j increments but i does not in the loop so the result will be:
i j
1 0
1 1
1 2
1 3
1 4
1 5
1 6

Then if you do anothe printf after i++ i will be 2 and j will be 7 since i have seen on the IDE outside for loop it is incremented by 1

For assignment 2:

i is 3, j is 2, k is 1
This is how it was able to run in the IDE, if i put a semi-colon where for ends it gave an error.
#include<stdio.h>

int main()
{
int i, j, k;

for(i = 1, j =0, k = 3; i < 5 && j <= 6 && k > 1; i++, j++, k--)
{
printf("%d %d %d\n", i, j, k);
}
printf("end\n");
printf("%d %d %d\n", i, j, k);
return 0;
}

maryannemuthoni
Автор

4:55 ma'am said that if we don't initialize anywhere, we'll get no o/p. But I got an o/p when I ran the program.
#include <stdio.h>
#include <conio.h>
int main()
{
int i;
for(;i<5;i++)
printf("%d", i);
return 0;
getch();
}
output:
01234
7:58#include <stdio.h>
#include <conio.h>
int main()
{
int i, j=0;
for(;i<5;i++)
printf("%d %d\n", i, j);
return 0;
getch();
}
output:
0 0
1 0
2 0
3 0
4 0
14:10 #include <stdio.h>
#include <conio.h>
int main()
{
int i, j;
for(i=1, j=0;i==10;i++, j++)
printf("%d %d\n", i, j);
return 0;
getch();
}
output
(blank screen, nothing is printed) // I didn't understand the logic here
24:33 #include <stdio.h>
#include <conio.h>
int main()
{
int i, j;
for(i=1, j=0;i<5, j<=6;i++, j++);
printf("%d %d\n", i, j);
return 0;
getch();
}
output: 8 7
26:07#include <stdio.h>
#include <conio.h>
int main()
{
int i, j;
for(i=1, j=0;i<5, j<=6;j++);
printf("%d %d\n", i, j);
i++;
return 0;
getch();
}
output: 1 7
26:47 #include <stdio.h>
#include <conio.h>
int main()
{
int i, j, k;
for(i=1, j=0, k=3;i<=5, j<=6, k>1;i++, j++, k--);
printf("%d %d\n", i, j, k);

return 0;
getch();
}
output: 3 2 1

fatima
Автор

Mam u are just awesome 😊 I learn c very easily from your videos, thnx for making such a informative and easy to understand lectures. Thank you!!❤️

shahdarshil
Автор

your lectures are well put together, keep up the good work

simbarasheblessed
Автор

At 23:53 a small correction for loop will run infinite

uppeyvaishnavi
Автор

A very amazing season mam
I search this topic on u tube but your video are awesome
All concept clear thanks mam👍👍👍👍👍👍👍👍👍👍❤️❤️❤️❤️❤️❤️

Anonymous_EngineerX