JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: C Language in hindi

Matrix : Examples in c language in hindi , what is matrix in c , matrics example मैट्रिक्स क्या है c कंप्यूटर भाषा में

मैट्रिक्स क्या है c कंप्यूटर भाषा में , Matrix : Examples in c language in hindi , what is matrix in c , matrics example :-
हमने array को पढ़ा |array से matrix को बनाया जाता है | इस article मे,हम matrix के कुछ advance एक्सम्प्ले को पढ़गे |
उदहारण-1
Program for checking symmetric matrix.
इस उदाहरण मे , किसी 3*3 matrix को symmetric matrix की condition को check करना है |
Explantion
symmetric matrix यो matrix होती है जिसके लिए matrix ‘A ‘ ,transverse of  matrix ‘A’ equal होने चाहिए |इसके लिए algorithm होती है :
1.array के element को input किया जाता है |
2.matrix के transpose को निकला जाता है जिसे किसी दुसरे variable मे सेव किया जाता है |
3.फिर matrix और matrix का transpose equal होगा तब
3.i-matrix ,symmetric matrix है |
3.iiअन्यथा matrix ,symmetric matrix नहीं है |
input
     1 2 3
A=  4 5 6
     7 8 9
transpose of matrix ‘A’ :
    1 4 7
A= 2 5 8
    3 6 9
source code :
#include<conio.h>
#include<stdio.h>
void main()
{
int a[3][3];
int b[3][3];
printf(“Input element of array”);
for(int i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf(“%d”,&a[i][j]);
}
}
/* looping for find transpose matrix ‘A’ */
for(int i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
b[i][j]=a[j][i];
}
}
/* comparison start */
int count=0;
for(int i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(a[i]!=b[i][j])
{
count =1;
break;
}
/ print transpose of matrix*/
for(int i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“%d\\t”,b[i][j]);
}
printf(“\n”);
}
}
if(count ==1)
{
printf(“matrix is not symmetric matrix. “);
}
else
{
printf(“matrix is symmetric matrix. “);
getch();
}
इस उदहारण मे , जब
i=1 और j=0 तब a[1] [0] =b[0][1] assign होगा |जोकि symmetric matrix की  condition को फॉलो करता है |
आउटपुट होगा :
Input element of array 1 2 3 2 4 5 3 5 9
matrix is symmetric matrix.
उदहारण-2
Program for checking sparse matrix.
इस उदाहरण मे , किसी 3*3 matrix को sparse matrix की condition को check करना है |
Explanation
Sparse matrix वे  matrix होती है जिसमे matrix के ज्यादातर elements zero होती है |यहा पर हम assume करते है (i*j)/ 2 element zero होगे | इसके लिए algorithm होती है |  :
1.array के element को input किया जाता है |
2.फिर matrix के सभी element को zero से compare करते है |अगर zero होते है तब count की value बढ़ जाती है |
3.अगर count की value , (i*j)/ 2 ज्यादा होती जब matrix sparse matrix होती है |
source code :
#include<conio.h>
#include<stdio.h>
void main()
{
int a[3][3];
printf(“Input element of array”);
for(int i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“matrix “)
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
printf(“%d”,a[i][j]);
}
}
int count=0;
for(int i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(a[i][j]==0)
{
count ++;
}
}
if(count>=(3*3)/2)
{
printf(“matrix is not sparse matrix. “);
}
else
{
printf(“matrix is sparse matrix. “);
getch();
}
आउटपुट होगा :
Input element of array 2 4 5 0 7 0 5 0 0
matrix
2 4 5
0 7 0
5 0 0
matrix is not sparse matrix.
उदहारण-3
Program for checking identity matrix.
इस उदाहरण मे , किसी 3*3 matrix को identity matrix की condition को check करना है |
Explanation
Sparse matrix वे  matrix होती है जिसमे matrix के diagonal elements ‘1’  होती है | इसके लिए algorithm होती है |  :
1.array के element को input किया जाता है |
2.फिर matrix के सभी diagonal element को ‘1’ से compare करते है |diagonal element के लिए row और column की सख्या सामान होती है |
source code :
#include<conio.h>
#include<stdio.h>
#define R 3
#define C
void main()
{
int a[3][3];
printf(“Input element of array”);
for(int i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“matrix “)
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
printf(“%d”,a[i][j]);
}
}
int count=1;
for(int i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(i==j && a[i][j]!=0)
{
count = 0;
}
else if (i!=j && a[i][j]!=0)
{
count =0;
}
}
if(count==1)
{
printf(“matrix is an identity matrix. “);
}
else
{
printf(“matrix is not identity matrix. “);
getch();
}
आउटपुट होगा :
Input element of array 2 4 5 0 7 0 5 0 0
matrix
2 4 5
0 7 0
5 0 0
matrix is not identity matrix.
उदहारण-4
Program for interchange diagonal elements into matrix .
इस उदाहरण मे , किसी 3*3 matrix के सभी diagonal element को interchange करना चाहिए  |
source code :
#include<conio.h>
#include<stdio.h>
void main()
{
int a[3][3];
printf(“Input element of array”);
for(int i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“matrix “)
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
printf(“%d”,a[i][j]);
}
}
for(int i=0;i<3;i++)
{
i=j;
temp=a[i][j];
a[i][j]=a[i]a[(3-j)-1];
a[i]a[(3-j)-1]=temp;
}
printf(“matrix after interchange “)
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
printf(“%d”,a[i][j]);
}
}
getch();
}
आउटपुट होगा :
Input element of array 2 4 5 0 7 0 5 0 0
matrix
2 4 5
0 7 0
5 0 0
matrix after interchange
5 4 2
0 7 0
0 0 5
उदहारण-4
Program for calculate determinant of matrix .
इस उदाहरण मे , किसी 2*2  matrix की determinant को calculate करना है  |जैसे
4 6
5 6
इस matrix का determinant 24-30=-6
source code :
#include<conio.h>
#include<stdio.h>
void main()
{
int a[2][2];
printf(“Input element of array”);
for(int i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“matrix “)
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
printf(“%d”,a[i][j]);
}
}
int d;
d=a[0][0]*a[1][1]-a[0][1]*a[1][0];
printf(“Determinant = %d”,d);
getch();
}
आउटपुट होगा :
Input element of array 2 4 5 1
matrix
2 4
5 1
Determinant = -18
Sbistudy

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
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