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 - First Program of Loop (For Loop)
Tutorials Arena
Follow
10/13/2024
Category
š
Learning
Transcript
Display full video transcript
00:00
Now the same program which I have explained with the use of the while loop to display
00:09
the first three odd numbers, I am going to make the same program by use of for loop.
00:15
How to use the for loop?
00:18
I am going to explain with this simple program.
00:22
First of all I will save this new file, something like this I have given the name, here it should
00:39
show what C and C++ files, then save and I will start making the program, that is include
00:51
then I will use main, inside it I will use first OD then I, I will give the data type
01:04
also with it integer then OD equals to 1, I will use the for loop for I equals to 1,
01:14
I less than equals to 3 and then what I++ and here I will use what printf and inside
01:23
it I will write down slash n odd number is that is what percent d, where it is inside
01:36
the OD, at the last of the statement printf statement what semicolon then what OD equals
01:45
to OD plus 2 to get the next odd number, here I will write down what return 0 like this.
01:57
I will save it and let us first see if there is any error, so there is not any error,
02:06
let us run and see it's going to collect correct result, yes 1, 3 and 5.
02:12
How the things work let us understand, inside the for loop I have initialized the value of I that
02:19
is 1, it will come to the decision part, 1 less than 3 the condition is true, so it's going to
02:25
display the first odd number that is what 1, then 1 plus 2 that is 3, so 3 is going to store inside
02:31
OD and the value of I is going to increment, so either you write down I equal to I plus 1
02:39
or you write down I++, both the things are same, it's only going to increment by 1,
02:46
so the value of I is going to increment from 1 to what 2, so now the value of I is what 2,
02:53
it will come to the decision part, 2 less than 3 the condition is true, so it's going to display
02:58
what 3 as the last value inside OD it was 3, then 3 plus 2, 5 again the loop will carry on,
03:07
the value of I is going to increment from 2 to what 3, it will come to the decision part,
03:13
3 equal to 3, here is the condition is true, so next odd number it was 5, so it's going to display
03:19
5 and 5 plus 2, 7 again it will come here I++, now the value of I is what 4, 4 less than 3,
03:30
this loop will terminate and we will get what 1, 3 and 5, so we have seen the result,
03:39
we have run it and we have seen that it has displayed 1, 3 and 5.
03:44
Okay, the next video I will explain something else, thanks.
Recommended
3:55
|
Up next
Learn Programming Technique C to Master Skills - First Program of Loop (While 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
4:28
Learn Programming Technique C to Master Skills - Fourth Program of Loop ( For Loop )
Tutorials Arena
10/13/2024
8:01
Learn Programming Technique C to Master Skills - Loop Within Loop 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
5:33
Learn Programming Technique C to Master Skills - Fourth Program of Loop ( While Loop )
Tutorials Arena
10/13/2024
5:02
Learn Programming Technique C to Master Skills - Third Program of Loop
Tutorials Arena
10/17/2024
3:52
Learn Programming Technique C to Master Skills - Second Program of Loop (Flow Chart)
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
8:07
Learn Programming Technique C to Master Skills - Loop with if Statement Second 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
4:01
Learn Programming Technique C to Master Skills - Fourth Program of Loop ( Flow Chart )
Tutorials Arena
10/13/2024
7:02
Learn Programming Technique C to Master Skills - Sixth Program of Array (Loop with if)
Tutorials Arena
11/1/2024
8:06
Learn Programming Technique C to Master Skills - Linked List ( First Program)
Tutorials Arena
11/30/2024
3:16
Learn Programming Technique C to MasterĀ Skills - First Program of Function ( Continue ...)
Tutorials Arena
11/3/2024
12:26
Learn Programming Technique C to Master Skills - First Program of Array
Tutorials Arena
10/20/2024
6:03
Learn Programming Technique C to Master Skills - Linked List ( Second Program)
Tutorials Arena
11/30/2024
9:09
Learn Programming Technique C to Master Skills - Second Program( Call by Reference)
Tutorials Arena
11/8/2024
6:04
Learn Programming Technique C to Master Skills - First Program (Array with Function , Call by Value)
Tutorials Arena
11/9/2024
8:18
Learn Programming Technique C to Master Skills - Loop Within Loop Program Explanation in Flow chart
Tutorials Arena
10/17/2024
4:09
Learn Programming Technique C to Master Skills - Linked List ( Delete First Node Program )
Tutorials Arena
12/1/2024
11:41
Learn Programming Technique C to Master Skills - Second Program of Array
Tutorials Arena
11/1/2024
9:12
Learn Programming Technique C to Master Skills - Program of Recursion
Tutorials Arena
11/6/2024