Category
š
LearningTranscript
00:00Hi I am Sandeep today I am going to explain that how to display the odd numbers but we
00:09are not going to display the first three odd numbers this is the program of user choice
00:17how many odd numbers we have to display okay so as many odd numbers we want we can display
00:25that is according to our will okay so it's a user choice program let us understand for
00:32that I have taken three variables I have taken for odd number od to count the odd numbers
00:39I have taken i and how many times the loop is going to carry on for that I have taken
00:44an extra variable n okay I have initialized the value of od that is 1 and I have initialized
00:51the counter variable i equals to 1 now how many times the loop will carry on for that
00:57I have to input the value inside this variable n suppose I have input 3 so this loop is going
01:06to carry on for how many times three times so how many odd numbers I am going to get
01:12I am going to get three odd numbers so let us do the try run 1 less than 3 as inside
01:18n it is 3 and the value of i is 1 1 less than 3 the condition is true it will come
01:23to the yes part it's going to display 1 okay then 1 plus 2 that is what 3 so inside od
01:31it is 3 what is inside i it is 1 1 plus 1 that is what 2 so remember the values inside
01:38od it is 3 inside i it is 2 the loop will carry on 2 less than 3 the condition is true
01:46okay so it's going to print the odd number as the condition is true what was the value
01:52of od it was 3 so it's going to display 3 now it will come to this equation 3 plus 2
01:57that is what 5 just remember the values the value of od is what 5 it will come to the
02:04counter variable 2 plus 1 that is what 3 so the new value of i is what 3 earlier value
02:13is over written by the new value so the value of i is what 3 and the value of od is what
02:175 okay again the loop will carry on 3 equal to 3 as the value inside i is 3 and value
02:25of n is what 3 so 3 equal to 3 the condition is true what is inside od it is 5 so 5 is
02:33going to display okay then 5 plus 2 7 and 3 plus 1 4 again the loop will carry on 4
02:41less than 3 the condition false no and stop okay so as we have given the value of n 3
02:48so this loop carry on for 3 times if i give the value of n 2 so how many times this loop
02:55is going to carry on for 2 times let us check value of i is 1 1 less than 2 the condition
03:02is true so 1 is going to print and 1 plus 2 that is what 3 so the new value of od is
03:08what 3 1 plus 1 that is what 2 it will check here 2 equals to 2 yes the condition is true
03:17what is inside od it is 3 so 3 is going to print okay and then what 3 plus 2 5 and 2
03:24plus 1 3 so 3 less than 2 as the value of n is 2 and the value of i is 3, 3 less than
03:312 the condition will get false and then stop so we get the two odd numbers 1 and 3.
03:36So whatever the value is you are going to input inside n that times the loop is going
03:43to carry on okay for that times the loop is going to carry on I hope you understand how
03:49to use user choice program how to make it in the next video I am going to make the program
03:55the same program okay in C. Thanks