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 - Fifth Program of Array
Tutorials Arena
Follow
10/20/2024
Category
š
Learning
Transcript
Display full video transcript
00:00
Hello everyone, this is Sandeep. Now I am going to explain this sixth number program
00:09
and what the program is let us see. Input five numbers in array then copy it into another
00:16
array in reverse order. So we have to copy the elements of first array into second array
00:27
and that we have to copy in a reverse order. So how to do this let us see okay.
00:35
I am going to make the program. First thing what I will do, I will store the values, I
00:47
will store the elements inside the first array okay. Let us quickly give the name to it to
01:00
the program okay and save it. I will use what int main and inside it I will first of all
01:15
declare two arrays A having five elements and one more array B which is also going to store
01:24
five elements. I will take two extra variables one is I another one is what J okay. Now I will
01:35
give a message here that is to store the value inside the first array variable and put the values
01:43
inside first array okay. We are going to store the five elements inside the first array. For
01:59
that I will apply the loop I equals to zero I less than five okay I plus plus like this.
02:07
Then scanf inside the inverted comma percent e comma and a I. So the loop will carry on for
02:25
five times and the values are going to store inside the A array. Now for the logic part I
02:33
would again apply the loop I equals to zero okay and J equals to four like this as I have to
02:45
initialize both the values of I and J okay. So I will use the comma then I less than five okay.
02:55
So what I plus plus comma J minus minus okay. So one of the loop is in an incrementation form
03:07
and another loop in decrementation form both I have used inside this for loop and what I
03:15
will write down here a J equals to a I. So whatever the value which is there inside the
03:26
index position of I that is going to store inside the index position of J okay. Once all the things
03:35
will be done all the values will be stored inside the P array in the second array okay
03:43
and we have to display it. So for that int have values or numbers stored in reverse order okay.
03:58
For that for I equals to zero I less than five I plus plus okay and then we have to display it.
04:14
So what int f person D comma B I okay. So the resulted value is inside the secondary B okay
04:39
and then it's going to display. I give some space also so that after each value there should be
04:50
space okay and here I should use slash n so that I should input the value from the next row okay
05:07
and here also slash n. Let us save, let me run one time and then I will see is it going to give
05:17
the correct result or not. Here it should be what semicolon as it's giving the error let us see
05:23
what the error is showing. Error which it is showing is that semicolon before this basis
05:32
okay. So I haven't used it, I will use it. I will click on build so it's showing me zero
05:39
and zero warning. Let us run. So I'm going to input the values inside the first array five
05:46
three one okay two like this one more four. It should show me in a reverse order so it's
05:59
showing me first four then two then one then three then five okay. So the execution is fine
06:08
the program is right okay. Now we have to understand how it's going to work. So I have
06:15
applied the loop to input the values inside the array okay all the values are stored. Suppose
06:20
the values are these three six seven two and five. So I have carry on the loop and the values
06:29
are stored inside the array okay. Now I have again applied the loop for loop okay and inside it
06:37
here if you see I have to see the logical part the value of i is what zero okay the value of j
06:45
is what four okay and it will come to the decision part zero less than five the condition is true
06:52
when the zero is less than zero is less than five the condition is true. So what we are doing the
06:59
value which is there inside the zeroth index position we are going to store inside the fourth
07:05
index position of the secondary okay. So let us see what is value there inside the zero index
07:16
position and the zero index position it is three okay and that value is going to store inside the
07:26
it is going to store here inside the fourth index position here okay. Then the value of j
07:41
is going to decrement from four it will be what three and the value of i is going to increment
07:48
from zero it is going to what one. One less than five the condition is true what is there inside
07:55
the first index position of array and the first index position of an array it is six okay and
08:07
what is there the value of j it is three so the value which is there inside the
08:19
first index position that is going to store inside the b array okay third position okay
08:27
inside third index position. So from the first index position of a array the value is going to
08:33
store inside the from here it is going to store here okay I just indicate to here.
08:42
So in this way I hope you understand in this way this loop is going to carry on
08:48
there will be decrement of j and there will be increment of i okay and in this way the values
08:56
is going to store in the in the reverse order inside the secondary okay once the loop will
09:04
terminate this loop will terminate okay. I have again applied the loop to show the values inside
09:11
the b array in reverse order so I have displayed I have used a printf to display the message that
09:21
is values stored in reverse order in this in the secondary for that I have applied the loop
09:26
on where when the values are going to display okay. So I hope you understand it
09:32
in the next video I will explain some another program. Thanks for today.
Recommended
12:37
|
Up next
Learn Programming Technique C to Master Skills - Fourth Program of Array
Tutorials Arena
10/20/2024
9:58
Learn Programming Technique C to Master Skills - Third Program of Array
Tutorials Arena
11/1/2024
11:41
Learn Programming Technique C to Master Skills - Second Program of Array
Tutorials Arena
11/1/2024
12:26
Learn Programming Technique C to Master Skills - First Program of Array
Tutorials Arena
10/20/2024
7:30
Learn Programming Technique C to MasterĀ Skills - Fifth Program of Function
Tutorials Arena
11/3/2024
7:02
Learn Programming Technique C to Master Skills - Sixth Program of Array (Loop with if)
Tutorials Arena
11/1/2024
13:04
Learn Programming Technique C to Master Skills - Double Dimension Array Program
Tutorials Arena
10/20/2024
3:40
Learn Programming Technique C to Master Skills - Array of Pointer Program
Tutorials Arena
11/9/2024
4:22
Learn Programming Technique C to Master Skills - Pointer And Arrays Program
Tutorials Arena
11/9/2024
12:03
Learn Programming Technique C to Master Skills - Array of Structure Program
Tutorials Arena
11/10/2024
6:40
Learn Programming Technique C to Master Skills - Explanation 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
9:47
Learn Programming Technique C to Master SkillsCharacter String Fifth Program
Tutorials Arena
11/19/2024
5:02
Learn Programming Technique C to Master Skills - Third Program of Loop
Tutorials Arena
10/17/2024
5:27
Learn Programming Technique C to MasterĀ Skills - Sixth Program of Function
Tutorials Arena
11/6/2024
3:37
Learn Programming Technique C to Master Skills - Pointers And Arrays
Tutorials Arena
11/8/2024
7:10
Learn Programming Technique C to Master SkillsCharacter String Fourth Program
Tutorials Arena
11/19/2024
7:12
Learn Programming Technique C to Master Skills - Third Program (Passing Entire Array in Function)
Tutorials Arena
11/9/2024
4:51
Learn Programming Technique C to MasterĀ Skills - Seventh Program of Function - I
Tutorials Arena
11/3/2024
9:14
Learn Programming Technique C to Master Skills - Fourth Program (Call by Reference)
Tutorials Arena
11/8/2024
9:20
Learn Programming Technique C to Master Skills - Union Program
Tutorials Arena
11/10/2024
4:01
Learn Programming Technique C to Master Skills - Fourth Program of Loop ( Flow Chart )
Tutorials Arena
10/13/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
4:54
Learn Programming Technique C to Master SkillsCharacter String Fifth Program ( Flowchart)
Tutorials Arena
11/19/2024