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 - Double Dimension Array Program
Tutorials Arena
Follow
10/20/2024
Category
š
Learning
Transcript
Display full video transcript
00:00
Hello everyone, today I am going to explain program of double dimension array and in this
00:10
program I am going to cover to display the matrix 2 by 2.
00:18
So if I have to display matrix 2 by 2, how I am going to do this?
00:23
For this 7th number program I am going to perform that is to display 2 by 2 matrix ok.
00:36
For that I have to use double dimension array and when I declare double dimension array
00:49
the first two represents to the rows and the second one represents to the column, it will
00:59
be like this.
01:00
Let me again write down how the declaration will be.
01:08
It will be like int a, the first one two represents to rows and the second one represents to the
01:16
column.
01:17
As I have to store the values in rows and columns, so at the run time the memory which
01:23
is going to allocate is going to allocate in this way.
01:28
This particular cell, this particular memory space will be called the 0 row 0 column ok.
01:36
Then row will be the same but the column gets changed, so this particular cell position
01:41
will be called 0 row first column, then the rows then the row gets changed, so this particular
01:48
cell will be called first row 0 column and then what first row first column.
01:54
So in a sequence way the memory is going to allocate and then values are going to store
02:00
inside it.
02:02
And I have a draw in this way in a matrix form as I have to make the program of a matrix
02:10
ok.
02:11
I have shown thus values in the location in a matrix form ok and in this way the values
02:20
are also going to display ok.
02:23
But actually the memory location which is going to allocate that is allocate in a sequence
02:29
form ok.
02:31
So I am going to quickly make the program, as I have explained that this is the 0th row
02:40
first column and in the 0th row first column this is the first value which is stored.
02:45
In the 0th row first column there is the second value which is going to store, in the first
02:50
row 0th column there is another value which is stored, in the first row first column this
02:57
20 is going to store ok.
02:59
And then the same formation as for the convenient I have explained in a matrix form the display
03:09
also will be in the same way 20 10 30 and 20.
03:12
So how to do this for that I have to apply loop within loop ok and here I am going to
03:22
make the program of it to store the values inside that double dimension array and then
03:30
to display in a matrix form.
03:32
So let us see, let me save also it ok, first thing what I will do I will declare double
03:51
dimension array that is int a 2 and then again 2 which is having two rows and two columns
04:01
ok.
04:02
With it I will use two variables also i and j, i is going to go with the rows and j is
04:09
going to go with the columns, here I will give a message what input values ok.
04:19
So I have given a message here values which I have to input, so to input it I have to
04:23
apply the loop i equals to 0 then what i less than equal to 1 and i plus plus ok and inside
04:34
it I will again apply the loop that is j equals to 0, j less than equal to 1 and then what
04:41
j plus plus ok.
04:44
So the second loop is going to go to the column, the outer loop is going to go to rows.
04:49
Now with the scanf I will use %d, and a i and then what j ok, in this way the values
05:03
are going to store inside the double dimension array but I have to display it in a matrix
05:10
form, so here I will give a message display of values in form of 2 by 2 matrix ok.
05:35
So to do this what I will do, I will again apply the loop for i equals to 0, i less than
05:44
equals to 1 and then what i plus plus inside it I will again apply the loop for the columns
05:51
to cover i j equals to 0, j less than equal to 1 and then what j plus plus ok and then
06:02
I will write on what printf %d, and sign and sorry not and sign then I have to give
06:16
the location a i and here what j and below of it printf some spaces ok.
06:31
When the inner loop will terminate then I have to take the cursor on the next row for
06:36
that I will use what slash n, so I hope everything is fine and it's going to work perfectly.
06:45
Let me save it, just click on build ok and run the program it's asking me to input the
06:54
values so let me input the four values ok.
06:59
Now let us press the enter key and I press it so it is displayed in the 2 by 2 matrix
07:04
form ok.
07:05
So let us understand when I have applied the loop, when I have applied loop within loop
07:10
and we have understand how the loop within loop works, I have explained the programs
07:15
of loop within loop how it works in my previous videos ok.
07:20
So it will start the value of i is what 0, 0 less than 1 condition is true, it will come
07:26
to the inner loop the value of j is what 0, 0 less than 1 the condition is true, so we
07:31
are talking about 0 row 0 column position that is at this position ok.
07:36
Suppose I input 50, so the 50 is going to store here in 0 row 0 position ok of double
07:45
dimension array then the value of j is going to increment by 1, 1 equal to 1 the condition
07:51
is true.
07:52
Now i is what 0 but j gets changed it's 1, so we are talking about 0 1 position, so 0
07:59
1 position is where this one, so the next value which the scanf is going to read and
08:05
store that is inside the 0 and 1st, 0 row 1st column ok.
08:12
And again the value of j is going to increment to 2, 2 less than 1 condition get false it's
08:17
going to the outer loop, the value of i is going to increment by 1, 1 equal to 1 the
08:23
condition is true again it will come in the inner loop it will start from its initial
08:27
value the value of j is what 0, 0 less than 1 the condition is true.
08:32
Now which position we are talking the value of i is 1 but the value of j is what 0, so
08:39
we are talking about this position, so suppose we have input 85, so that is going to 86 that
08:44
is going to store in this position then the value of j is going to increment by 1, 1 equal
08:52
to 1 the condition is true, now this time the value of i is also 1, the value of j is
08:57
also 1, so the next value which is going to store that is in the 1st row 1st column ok.
09:04
Now these values are stored but we have to display in a matrix form, so for that I have
09:09
again applied loop within loop ok and I have given a message first again the loop will
09:15
start the value of i is 0, 0 less than 1 the condition is true it's come to the inner loop
09:20
the value of j is 0, 0 less than 1 the condition is true we are talking about the 0, 0 position
09:26
of an array from here that the value is going to display on the screen with some space also.
09:35
So what is the value inside the memory it's 50 that is going to display on the screen
09:40
ok then the value of j is going to increment to 1, 1 equal to 1 the condition is true,
09:48
so the value of i is 0 but the j gets changed to 1, so we are talking about the 0, 1 position
09:56
that is this position, so value will come and then after some space it's going to display
10:04
ok then what will happen the value of j is going to increment to 2, 2 less than 1 condition
10:11
get false it will go to the outer loop the value of i is going to increment by 1.
10:16
Now the value of form of i from 0 it's now 1 it will come to the decision part 1 equal
10:22
to 1 the condition is true again it will come to the inner loop which is going to start
10:28
from its initial value that is 0 will come to the decision part 0 less than 1 the condition
10:33
is true.
10:34
Now this time the value of i is 1 but the value of j is what 0, so we are talking about
10:41
this position 1 0 ok, so the next value which is going to display ok that is on the next
10:48
row because why it's going to display on the next row because when this loop was terminated
10:57
when the value of j from 1 when it was 2, 2 less than 1, so when this inner loop terminated
11:06
this it find what printf and it's having what slash n the cursor which was blinking after
11:16
the display of 70 ok it will come here down to this position after 70 it's came down and
11:25
then the value of i increment to 1, 1 equal to 1 the condition is true it will come here
11:33
to the inner loop inner for loop where the value of j is what 0, 0 less than 1 condition
11:40
is true.
11:41
So now this time we are talking about 1 0 position ok, so what is the value inside the
11:46
1 0 position that is what 86 that is going to display on the screen ok I hope you understand
11:52
with some space ok then the value of j is going to increment by 1, 1 equal to 1 the
12:00
condition is true now we are talking about the first row and the first column as the
12:04
value of i is 1 and the value of j is also 1 ok.
12:08
So let us see what is there in the first row first column it is 90 so after some space
12:13
it's going to display then the value of j is going to increment by 2, 2 less than 1
12:21
condition gets false this loop will terminate the cursor will come on the next row by the
12:27
use of slash n it will go to the outer loop the value of i increment to 2 ok it will come
12:34
to this part to the decision 2 less than 1 here also the condition will get false but
12:40
we will get the final result that is in a matrix form in a 2 by 2 matrix formation we
12:50
get the result ok so this is the program friends which I have explained of 2 by 2 matrix
12:59
in the next video I will explain something else thanks.
Recommended
11:41
|
Up next
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
9:58
Learn Programming Technique C to Master Skills - Third Program of Array
Tutorials Arena
11/1/2024
3:40
Learn Programming Technique C to Master Skills - Array of Pointer Program
Tutorials Arena
11/9/2024
12:37
Learn Programming Technique C to Master Skills - Fourth Program of Array
Tutorials Arena
10/20/2024
4:22
Learn Programming Technique C to Master Skills - Pointer And Arrays Program
Tutorials Arena
11/9/2024
9:40
Learn Programming Technique C to Master Skills - Fifth Program of Array
Tutorials Arena
10/20/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
14:36
Learn Programming Technique C to Master Skills - Program of Sum of two Matrices
Tutorials Arena
11/1/2024
17:20
Learn Programming Technique C to Master Skills - Program of Multiplication of two Matrices
Tutorials Arena
11/1/2024
3:37
Learn Programming Technique C to Master Skills - Pointers And Arrays
Tutorials Arena
11/8/2024
4:14
Learn Programming Technique C to Master Skills - Explanation of Second Program
Tutorials Arena
10/8/2024
8:07
Learn Programming Technique C to Master Skills - Loop with if Statement Second Program
Tutorials Arena
10/17/2024
9:20
Learn Programming Technique C to Master Skills - Union Program
Tutorials Arena
11/10/2024
5:02
Learn Programming Technique C to Master Skills - Third Program of Loop
Tutorials Arena
10/17/2024
8:04
Learn Programming Technique C to Master Skills - File Handling Second Program
Tutorials Arena
11/18/2024
8:08
Learn Programming Technique C to MasterĀ Skills - First Program of Function
Tutorials Arena
11/3/2024
5:23
Learn Programming Technique C to Master SkillsCharacter String Second Program
Tutorials Arena
11/19/2024
7:02
Learn Programming Technique C to Master Skills - Sixth Program of Array (Loop with if)
Tutorials Arena
11/1/2024
9:12
Learn Programming Technique C to Master Skills - Program of Recursion
Tutorials Arena
11/6/2024
5:14
Learn Programming Technique C to Master Skills - Single If Statement Program Explanation
Tutorials Arena
10/12/2024
4:55
Learn Programming Technique C to Master Skills - Linked List Program
Tutorials Arena
12/2/2024
6:03
Learn Programming Technique C to Master Skills - Linked List ( Second Program)
Tutorials Arena
11/30/2024
7:56
Learn Programming Technique C to Master Skills - Nested If Statement Program
Tutorials Arena
10/12/2024