JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Categories: c++ language in hindi

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 किया है |

Sbistudy

Recent Posts

सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है

सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…

10 hours ago

मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the

marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…

10 hours ago

राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi

sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…

2 days ago

गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi

gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…

2 days ago

Weston Standard Cell in hindi वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन

वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन Weston Standard Cell in…

3 months ago

polity notes pdf in hindi for upsc prelims and mains exam , SSC , RAS political science hindi medium handwritten

get all types and chapters polity notes pdf in hindi for upsc , SSC ,…

3 months ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now