हिंदी माध्यम नोट्स
Write a program to add two matrix with function , subtract two Matric with function , transpose a matrix
इससे पहले के article मे function को array और struture के साथ use करने के method को discuss किया गया है | अब इस article मे , array और struture के कुछ उदाहरनो को discuss करेगे |
उदाहरन -1
Write a program to add two matrix with function .
इस उदाहरन मे , function द्वारा दो matrix को add किया जाता है |
Explanation
किसी matrix को implement करने के लिए two dimensional array को use किया जाता है | two level looping को भी use किया जता है |
1.सबसे पहले दो two dimensional array को declare किया जाता है | इसके बाद यूजर द्वारा दो array के elements को input किया जाता है |
2.looping होती है :-
इस loop से two dimensional array मे यूजर द्वारा input किये गये value को read किया जाता है |
3.इसके बाद addition() function array को pass किया जाता है |
3. उसके बाद addition() से प्राप्त को array variable ‘c’ मे assign किया जाता है |
addition () मे
addition() मे दोनों array variable को array variable ‘a’ और ‘b’ मे initial किया जता है |
looping की जाती है :-
इसमें int c[i][j] = a[i][j]+b[i][j] से addition को calculate किया जाता ही |
इसके बाद मर्त्रिक्स ‘c’ को return किया जता है |
Source code
#include<iostream.h>
#include<conio.h>
void add (int first[3][3] , int second [3][3] );
void main()
{
int first[3][3];
cout<<“Enter First Matrix Element : “;
for(i=0;i<3;i++)
{
for(j=0;j,3;j++)
{
cin>>first[i][j];
}
int second[3][3];
cout<<“Enter Second Matrix Element : “;
for(i=0;i<3;i++)
{
for(j=0;j,3;j++)
{
cin>>second[i][j];
}
int output[3][3];
output = add(first , second ) ;
cout<<“Addition Matrix :”;
for(i=0;i<3;i++)
{
for(j=0;j,3;j++)
{
cout<<output[i][j];
}
}
getch();
}
void add(int a[][] ,int b[][])
{
int o[3][3];
for(i=0;i<3;i++)
{
for(j=0;j,3;j++)
{
o[i][j]=a[i][j]+b[i][j];
}
}
return o;
}
उदाहरन -2
Write a program to subtract two Matric with function .
इस उदाहरन मे , function द्वारा दो matrix को subtract किया जाता है |
Explanation
किसी matrix को implement करने के लिए two dimensional array को use किया जाता है | two level looping को भी use किया जता है |
1.सबसे पहले दो two dimensional array को declare किया जाता है | इसके बाद यूजर द्वारा दो array के elements को input किया जाता है |
2.looping होती है :-
इस loop से two dimensional array मे यूजर द्वारा input किये गये value को read किया जाता है |
3.इसके बाद sub() function array को pass किया जाता है |
3. उसके बाद sub() से प्राप्त को array variable ‘c’ मे assign किया जाता है |
subition () मे
subition() मे दोनों array variable को array variable ‘a’ और ‘b’ मे initial किया जता है |
looping की जाती है :-
इसमें int c[i][j] = a[i][j] – b[i][j] से subtract को calculate किया जाता ही |
इसके बाद मर्त्रिक्स ‘c’ को return किया जता है |
Source code
#include<iostream.h>
#include<conio.h>
void sub (int first[3][3] , int second [3][3] );
void main()
{
int first[3][3];
cout<<“Enter First Matrix Element : “;
for(i=0;i<3;i++)
{
for(j=0;j,3;j++)
{
cin>>first[i][j];
}
int second[3][3];
cout<<“Enter Second Matrix Element : “;
for(i=0;i<3;i++)
{
for(j=0;j,3;j++)
{
cin>>second[i][j];
}
int output[3][3];
output = sub(first , second ) ;
cout<<“subtract Matrix :”;
for(i=0;i<3;i++)
{
for(j=0;j,3;j++)
{
cout<<output[i][j];
}
}
getch();
}
void sub(int a[][] ,int b[][])
{
int o[3][3];
for(i=0;i<3;i++)
{
for(j=0;j,3;j++)
{
o[i][j]=a[i][j]-b[i][j];
}
}
return o;
}
उदाहरन -3
Write a program to transpose a matrix with function .
इस उदाहरन मे , function द्वारा दो matrix को transpose tract किया जाता है |
Explanation
किसी matrix को implement करने के लिए two dimensional array को use किया जाता है | two level looping को भी use किया जता है |
1.सबसे पहले एक two dimensional array को declare किया जाता है | इसके बाद यूजर द्वारा array के elements को input किया जाता है |
2.looping होती है :-
इस loop से two dimensional array मे यूजर द्वारा input किये गये value को read किया जाता है |
3.इसके बाद transpose() function array को pass किया जाता है |
3. उसके बाद transpose() से प्राप्त को array variable ‘c’ मे assign किया जाता है |
transposeition () मे
transposeition() मे दोनों array variable को array variable ‘a’ मे initial किया जता है |
looping की जाती है :-
इसमें int c[i][j] = a[j][i] से transpose को calculate किया जाता ही |
इसके बाद matrix ‘c’ को return किया जता है |
Source code
#include<iostream.h>
#include<conio.h>
void transpose (int first[3][3]);
void main()
{
int first[3][3];
cout<<“Enter Matrix Element : “;
for(i=0;i<3;i++)
{
for(j=0;j,3;j++)
{
cin>>first[i][j];
}
int output[3][3];
output = transpose(first ) ;
cout<<“transpose Matrix :”;
for(i=0;i<3;i++)
{
for(j=0;j,3;j++)
{
cout<<output[i][j];
}
}
getch();
}
void transpose(int a[][])
{
int o[3][3];
for(i=0;i<3;i++)
{
for(j=0;j,3;j++)
{
o[i][j]=a[j][i];
}
}
return o;
}
उदाहरन -4
Write a program to dividetwo matrix with function .
इस उदाहरन मे , function द्वारा दो matrix को divideकिया जाता है |
Explanation
किसी matrix को implement करने के लिए two dimensional array को use किया जाता है | two level looping को भी use किया जता है |
1.सबसे पहले दो two dimensional array को declare किया जाता है | इसके बाद यूजर द्वारा दो array के elements को input किया जाता है |
2.looping होती है :-
इस loop से two dimensional array मे यूजर द्वारा input किये गये value को read किया जाता है |
3.इसके बाद div() function array को pass किया जाता है |
3. उसके बाद div() से प्राप्त को array variable ‘c’ मे assign किया जाता है |
subition () मे
subition() मे दोनों array variable को array variable ‘a’ और ‘b’ मे initial किया जता है |
looping की जाती है :-
इसमें int c[i][j] = a[i][j] / b[i][j] से divide को calculate किया जाता ही |
इसके बाद मर्त्रिक्स ‘c’ को return किया जता है |
Source code
#include<iostream.h>
#include<conio.h>
void div(int first[3][3] , int second [3][3] );
void main()
{
int first[3][3];
cout<<“Enter First Matrix Element : “;
for(i=0;i<3;i++)
{
for(j=0;j,3;j++)
{
cin>>first [i][j];
}
int second[3][3];
cout<<“Enter Second Matrix Element : “;
for(i=0;i<3;i++)
{
for(j=0;j,3;j++)
{
cin>>second[i][j];
}
int output[3][3];
output = div(first , second ) ;
cout<<“divide Matrix :”;
for(i=0;i<3;i++)
{
for(j=0;j,3;j++)
{
cout<<output[i][j];
}
}
getch();
}
void div(int a[][] ,int b[][])
{
int o[3][3];
for(i=0;i<3;i++)
{
for(j=0;j,3;j++)
{
o[i][j]=a[i][j] / b[i][j];
}
}
return o;
}
इस article मे array को function के साथ इस्तेमाल करने के method को discuss किया है |
Recent Posts
मालकाना का युद्ध malkhana ka yudh kab hua tha in hindi
malkhana ka yudh kab hua tha in hindi मालकाना का युद्ध ? मालकाना के युद्ध…
कान्हड़देव तथा अलाउद्दीन खिलजी के संबंधों पर प्रकाश डालिए
राणा रतन सिंह चित्तौड़ ( 1302 ई. - 1303 ) राजस्थान के इतिहास में गुहिलवंशी…
हम्मीर देव चौहान का इतिहास क्या है ? hammir dev chauhan history in hindi explained
hammir dev chauhan history in hindi explained हम्मीर देव चौहान का इतिहास क्या है ?…
तराइन का प्रथम युद्ध कब और किसके बीच हुआ द्वितीय युद्ध Tarain battle in hindi first and second
Tarain battle in hindi first and second तराइन का प्रथम युद्ध कब और किसके बीच…
चौहानों की उत्पत्ति कैसे हुई थी ? chahamana dynasty ki utpatti kahan se hui in hindi
chahamana dynasty ki utpatti kahan se hui in hindi चौहानों की उत्पत्ति कैसे हुई थी…
भारत पर पहला तुर्क आक्रमण किसने किया कब हुआ first turk invaders who attacked india in hindi
first turk invaders who attacked india in hindi भारत पर पहला तुर्क आक्रमण किसने किया…