Skip to player
Skip to main content
Skip to footer
Search
Connect
Watch fullscreen
Like
Comments
Bookmark
Share
Add to Playlist
Report
Learn Programming Technique C to Master Skills - Fourth Program of Loop ( While Loop )
Tutorials Arena
Follow
10/13/2024
Category
š
Learning
Transcript
Display full video transcript
00:00
Hello everyone, today I'm going to make the program of user choice, that is to display
00:08
the odd numbers 1, 3 and 5 or more than that, it will work according to our choice.
00:18
So I have explained the flowchart of it, now I'm going to implement the program, okay.
00:25
So I will save it first of all, give a name to it, that is prg something like this, okay
00:40
and save.
00:41
First thing, I will use the header file, okay, then I will use what int mean, now let us
00:53
think about the variables, so variables will be od for the odd number, i to carry on the
00:59
loop and I take one extra variable n, okay, then I will initialize the value of od, okay
01:09
and I will initialize the value of i also, okay like this.
01:13
Now I will give a message here, that is input term as I have to carry on the loop, I will
01:22
use the scanf and inside it, I will write down %d, and n.
01:32
So I'm going to input the value of n from the keyboard, then I will apply the loop i
01:40
while i less than equals to n, so I'm comparing i with n, okay.
01:48
If the condition is true, then I will display the odd number, should be int f and here should
02:00
I write what inside the bracket, odd number is %d, where it is inside od like this, okay
02:14
and od equals to od plus 2 and i equal to i plus 1, here I use what return 0 for exit
02:30
status.
02:32
So this is the program friends, only the difference is that this time I have to give the value
02:41
from the keyboard that how many times the loop is going to work.
02:45
Let us click on build up and see if there is any error, so there is not any error.
02:51
I'm going to click on run, it will ask me that how many odd numbers I want to display,
02:58
suppose 5, so it's going to display 5, it is, okay, there is a minute mistake, I have
03:11
to use here 1, okay, for the odd number and here I should use what slash n, so the numbers
03:24
will display row by row, let me save it, click on build, let us again input suppose 5, so
03:38
it is going to display 5 odd numbers, 1, 3, 5, 7 and 9, okay.
03:45
If I again run it and suppose I input the term 3, so it is going to work for 3 times,
03:50
so it is going to display 3 odd numbers, 1, 3 and 5, okay, so we are giving the choice
03:56
and that many times the loop is going to work, okay.
04:02
I have taken 3 variables od, i and n, I have given the value of od that is 1, I have given
04:10
the value of i that is 1, okay, input term, so we are going to input the value inside
04:15
and suppose 3, so this loop is going to work for how many times, 3 times, okay, first of
04:22
all 1 less than 3, so 1 is going to print, then 1 plus 3, 1 plus 2 that is what 3, so
04:29
inside od it will be 3 and 1 plus 1, 2, the loop will carry on, 2 less than 3, the condition
04:36
is true, so 3 is going to print and 3 plus 2, 5, 2 plus 1, 3, now the new value inside
04:44
i is 3, again the loop will carry on, 3 equal to 3 as the value inside n is 3 and the value
04:50
inside i is 3, so 3 equals to 3, the condition is true, what is going to print, 5 and 5 plus
04:57
2, 7 and what here, 3 plus 1, 4, 4 less than 3, condition will get false, this loop will
05:05
terminate, it will get 1, 3 and 5, I am going to input that term, suppose 6, so it is displayed
05:16
as 6, okay, odd numbers, so it is up, it is according to our choice, whatever that value
05:26
will going to give inside n, that much time this loop is going to work, okay.
Recommended
4:28
|
Up next
Learn Programming Technique C to Master Skills - Fourth Program of Loop ( For Loop )
Tutorials Arena
10/13/2024
4:03
Learn Programming Technique C to Master Skills - Second Program of Loop ( For Loop )
Tutorials Arena
10/17/2024
4:07
Learn Programming Technique C to Master Skills - Second Program of Loop (While Loop)
Tutorials Arena
10/17/2024
3:55
Learn Programming Technique C to Master Skills - First Program of Loop (While Loop)
Tutorials Arena
10/13/2024
3:51
Learn Programming Technique C to Master Skills - First Program of Loop (For Loop)
Tutorials Arena
10/13/2024
4:01
Learn Programming Technique C to Master Skills - Fourth Program of Loop ( Flow Chart )
Tutorials Arena
10/13/2024
8:01
Learn Programming Technique C to Master Skills - Loop Within Loop Program
Tutorials Arena
10/17/2024
4:57
Learn Programming Technique C to Master Skills - Loop With If Statement Program ( Flow Chart )
Tutorials Arena
10/13/2024
5:02
Learn Programming Technique C to Master Skills - Third Program of Loop
Tutorials Arena
10/17/2024
3:27
Learn Programming Technique C to Master Skills - Third Program of Loop ( Flow Chart)
Tutorials Arena
10/17/2024
10:56
Learn Programming Technique C to Master Skills - Loop With If Statement Program
Tutorials Arena
10/13/2024
3:52
Learn Programming Technique C to Master Skills - Second Program of Loop (Flow Chart)
Tutorials Arena
10/17/2024
9:14
Learn Programming Technique C to Master Skills - Fourth Program (Call by Reference)
Tutorials Arena
11/8/2024
7:02
Learn Programming Technique C to Master Skills - Sixth Program of Array (Loop with if)
Tutorials Arena
11/1/2024
8:07
Learn Programming Technique C to Master Skills - Loop with if Statement Second Program
Tutorials Arena
10/17/2024
3:51
Learn Programming Technique C to Master Skills - First Program of Loop (Flowchart)
Tutorials Arena
10/13/2024
6:52
Learn Programming Technique C to Master Skills - Fourth Program - (Call by Reference - continue..)
Tutorials Arena
11/8/2024
12:37
Learn Programming Technique C to Master Skills - Fourth Program of Array
Tutorials Arena
10/20/2024
9:40
Learn Programming Technique C to Master Skills - Fifth Program of Array
Tutorials Arena
10/20/2024
7:35
Learn Programming Technique C to MasterĀ Skills - Fourth Program of Function
Tutorials Arena
11/3/2024
5:02
Learn Programming Technique C to Master SkillsCharacter String Fourth Program (Flowchart)
Tutorials Arena
11/19/2024
4:54
Learn Programming Technique C to Master SkillsCharacter String Fifth Program ( Flowchart)
Tutorials Arena
11/19/2024
12:06
Learn Programming Technique C to Master Skills - Continuous If Statement Program
Tutorials Arena
10/8/2024
7:30
Learn Programming Technique C to MasterĀ Skills - Fifth Program of Function
Tutorials Arena
11/3/2024
7:10
Learn Programming Technique C to Master SkillsCharacter String Fourth Program
Tutorials Arena
11/19/2024