Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
All right, so what we have to do in this exercise is simply to write a program that receives some and
some value and from the user so receives and from the user and based on these and we are going to receive
OK to receive or receive or read and values or better say, integers.
And we are going to sum all the odd numbers and to return and to basically print these some sum, all
the old numbers.
OK, so how we are going to do that, let's start with just creating the variable and reading this value
once again from the user and storing it inside of an variable.
So an answer and which is also the number of values, a number of values in a sequence of numbers that
we are going to insert.
Right.
So enter and some.
And now let's read this value from the user and story inside the variable and so storing inside variable
in.
And now what we are going to do is just to use some loop.
Right.
And this is going to be very, very simple.
Let's say we have here I sell for I equals to you.
To what?
To what should be I equal to R equals, let's say to one, as long as I use less than or equal to N.
Okay I plus plus.
So one way to do that is to use the for loop.
Another way to do that is to use the wire loop as long as it is greater than one or zero, whatever
you choose using the greater than or equal.
OK, so let's go with the four.
No problems with four equals to one as long as I is less than or equal to and basically are making the
easy duration in times.
OK, so now let's just read the value from the user.
Let's say we will have also additional variable called current value and we will simply read the value
from the users or print f cancer of value and zero value.
Now read this value from the user so it inside current value.
And now we have to ask a simple question.
If current value divided by two modulo two equals to one, which means it's it's an odd number, then
in this case we should basically some this solution, these value.
So let's say also all the sum will be equal to zero.
So on some will be equal to zero.
There you go on some loss equals two to watch to the current value.
OK, so that's how you sum up all the old values in this sequence.
And finally, you're going to print.
OK, so all that sum equals to percentage.
And there you go.
And yeah, I think that we covered up everything as we should, so let's build and run it to see that
everything works correctly so and will represent the size of the sequence.
So, for example, five, let's go like one, two, three, four and five.
So we have some problem.
So what's the problem?
Osam equals to some odd, very odd number.
Very strange.
So we can see here that we didn't specify is instead of the placeholder here instead of the percentage,
what will be the values of the value should be or something.
So let's hopefully build and run it once again and see that everything works correctly.
So one, two, three, four and five.
So all some equals to nine.
And let's make sure that five plus three, which is eight plus one, which is nine awesome.
And similar approach can also be done for finding also the even values and also finding the the odd
sum and the even some basically we can also find both of them in a sequence.
So these are kind of questions that a lot of teachers like to ask students.
But now you know how you can tackle this problem even without using arrays, which we haven't covered
up yet, but we will talk about them.
So you simply get some value from the user and they and specify the size of the sequence that you are
going to use.
Then you readjust these values one by one, asking some conditions.
And since you don't care to store these values for later, use it.
That's why probably this approach is one of the best.
So thank you guys for watching.
I'll see you in the next video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.