00:01
Hello, welcome to this lesson.
00:02
In this lesson, we would write a c plus first program that would count all numbers from, that would give a sum of all numbers from 1 to 50.
00:13
So for this, we will declare some, that is actually off to 0.
00:22
Then we'll use a 4 loop.
00:25
So i need to get that it's starting from 1.
00:29
Okay, and then it should be less and or equal to 0.
00:34
To 50, we add 1 to it when the count is not up to 50.
00:45
Okay, then here this is what we'll do.
00:47
Therefore, we see that the value is an odd number.
00:55
If it's an odd number, it means that it's no divisible by two.
01:00
So we have the iterator that is starting from 1 divided by 2.
01:10
Here we are using we are looking at the remainder if the remainder is not equal to zero okay so if we divide the number by two and the remainder is not equal to zero it means that we don't have an even number in that sense we have an old number so if this an old number then we would add one you would add that number to the sum that we we have so make it class because to the eye.
01:54
Okay, then after it then you will print user c out to print the odd sum of integers from 1 to 50 minutes.
02:22
I'll bring out a sum.
02:32
So let's run.
02:47
So odd sum of 80 years from 1 to 50.
02:51
50 is to that 6 to 5 right so for here i would actually know the sum before the addition so let me do a c -out and i will say some before add then odd okay so here i'll print the odd that i'll know beforehand and then i'll bring that out.
03:53
All right.
03:54
So let's run again.
04:06
So it says zero...