हिंदी माध्यम नोट्स
Categories: C Language in hindi
Array -Two Dimension Array 2D in hindi in c computer language दो डायमेंशन अर्रे क्या है हिंदी में
दो डायमेंशन अर्रे क्या है हिंदी में Array -Two Dimension Array 2D in hindi in c computer language :-
Two dimension array : Two dimension array मे data values दो subscripts मे store होती है |(i) row (ii) coloum |इसे array ओप्फ़ array भी कहते है |इसका struture matrix की तरह होता है |इसे matrix array भी कहते है |Matrix मे , data को row और coloum मे यव्स्थित करते है |
इसका syntax है :
data type array name [row size][column size];
data type : ये define करता है की array मे किस तरह का data type store होगा |
array name : ये array का नाम होता है |
row size: ये number of row को define करता है |
column size: ये number of column को define करता है |
उदहारण के लिए:
int a[3][2];
इस statement से एक 3*2 two dimension array बनती है जिसका नाम a और data type int है |इसमें 3 row और 2 column होती है |
Two dimension array, one dimension array की array होती है |सभी one dimension array का address / index 0 से start होता है |और two dimension array मे , index two डिजिट का होता है एक row (one dimension array) के index की value होती है |दूसरा column array(one dimension array)का index होता है |
Initializing of Two Dimension Array :
जैसे one dimension array को सीधे initial कर सक्लते है उसी प्रकार two dimension array को भी सीधे initial कर सकते है |
इसका syntax है |
data type array name[row size][column size] = { datas };
इस syntax datas मे row और column के सभी values लिखी जाती है |उदहारण के लिएय :-
int a[2][3]={1,2,3,4,5,6};
इस उदहारण मे , 1,2,3 पहले row के index ‘0’ के column 0, column 1,column 2 मे store होगा |और 4,5,6 दुसरे row के index ‘1’ के column 0, column 1,column 2 मे store होगा|
इसके अलावा ,प्रोग्रामर नीचे दिए गए syntax से भी two dimension array को initial कर सकता है |
data type array name[row size][column size] = { {row 1 datas}
{row 2 datas}
{……………….}
{……………….}
{row n datas } };
इसमें reader array values को सरलता से read कर सकता है |
इसके अलावा ,two dimension array को run time पर initial कर सकते है |इसमें looping का use होता है |
जब values की संख्या बहुत ज्यादा होती है जब इस methodology use करते है|
उदाहरण के लिए :
#include<stdio.h.
#include<conio.h>
void main()
{
int a[3][4];
int a[3][4];
printf(“Enter Array data\n”);
for(i=0;i<3;i++)
{
for(j=2;j<4;j++)
for(j=2;j<4;j++)
{
scanf(“%d”,&a[i][j]);
scanf(“%d”,&a[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
for(j=0;j<4;j++)
{
printf(“%d”,a[i][j]);
}
printf(“\n”);
}
}
}
getch();
}
ये उदहारण 3*4 की matrix print करना का है| जिसमे दो for loop से data को array के index मे store कराया गया है |और फिर दो for loops से data को write किया गया है |
आउटपुट होगा :
Enter Array data
12 23 27 54 65 54 23 34 36 78 79 23
12 23 27 54
65 54 23 34
36 78 79 23
उदहारण -2 :
/ Program for add two matrix*/
#include<stdio.h.
#include<conio.h>
void main()
{
int a[3][4];
int a[3][4];
int b[3][4];
printf(“Enter First Array data\n”);
for(i=0;i<3;i++)
{
for(j=2;j<4;j++)
for(j=2;j<4;j++)
{
scanf(“%d”,&a[i][j]);
scanf(“%d”,&a[i][j]);
}
}
printf(“\nEnter Second Array data\n”)
for(i=0;i<3;i++)
{
for(j=2;j<4;j++)
for(j=2;j<4;j++)
{
scanf(“%d”,&b[i][j]);
scanf(“%d”,&b[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
for(j=0;j<4;j++)
{
c[i][j]=a[i][j]++b[i][j];
}
}
printf(“\n Addition of two matrix \n”);
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
for(j=0;j<4;j++)
{
printf(“%d”,c[i][j]);
}
printf(“\n”);
}
getch();
इस प्रोग्राम मे चार for loops run हो रहे है:-
(i) Matrix ‘a’ के data को read करने के लिए |
(ii)Matrix ‘b’ के data को read करने के लिए |
(iii) Addition operation perform करने के लिए |
(iv) Output Matrix को print करने के लिए |
आउटपुट होगा :
Enter First Array data
12 23 43 43 47 76 54 58 32 34 21 12
Enter Second Array data
13 24 44 45 49 80 69 52 45 14 13 17
Addition of two matrix
15 47 87 88
96 156 123 110
77 48 34 29
Memory Representation :
Two dimension array continuous memory location मे store होती है| ये दो तरह के हो सकती है |
1.Row major:
इसमें datas, row wise store होती है | इसमें row 1 के datas पहले n locations पर store होती है |और row 2 के data उसके बाद store होते है |
2.Column Major:
इसमें datas, column wise store होती है | इसमें column 1 के datas पहले n locations पर store होती है |और column 2 के data उसके बाद store होते है |
Recent Posts
Question Tag Definition in english with examples upsc ssc ias state pcs exames important topic
Question Tag Definition • A question tag is a small question at the end of a…
2 weeks ago
Translation in english grammer in hindi examples Step of Translation (अनुवाद के चरण)
Translation 1. Step of Translation (अनुवाद के चरण) • मूल वाक्य का पता करना और उसकी…
2 weeks ago
Report Writing examples in english grammer How to Write Reports explain Exercise
Report Writing • How to Write Reports • Just as no definite rules can be laid down…
2 weeks ago
Letter writing ,types and their examples in english grammer upsc state pcs class 12 10th
Letter writing • Introduction • Letter writing is an intricate task as it demands meticulous attention, still…
2 weeks ago
विश्व के महाद्वीप की भौगोलिक विशेषताएँ continents of the world and their countries in hindi features
continents of the world and their countries in hindi features विश्व के महाद्वीप की भौगोलिक…
2 weeks ago
भारत के वन्य जीव राष्ट्रीय उद्यान list in hin hindi IAS UPSC
भारत के वन्य जीव भारत में जलवायु की दृष्टि से काफी विविधता पाई जाती है,…
2 weeks ago