SlideShare une entreprise Scribd logo
1  sur  16
May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX)




Type array [size1][size2];



          Row           A[ i ][ j ]
   Column




#include <iostream.h>
#include <conio.h>
#include <math.h>
#include <cstring.h>




                                                1. int
                                                   2. float
                                            3. string
                                         4. char




                                                              Int const size1=?,size2=?;


      1   Programming C++ ©by ARAM-CSD
May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX)

                                              x     x
                                                                     x       x



Int array[size1][size2];

          int i,j;                       i,j,n,k,l,m,

                                                                                             main()

                                                                                                      {




                                                                                 cin, cout,if,
      for(i=0;i<size1;i++)
      {
      for(j=0;j<size2;j++)
      {
      _____
      _____
      }}
                                                                     size1         i
                                                                                   size1
                                                                         size2       j
                                                                                   size2
                                  n=2                   A2x2                           cin>>
      for(i=0;i<n;i++)
      {
      for(j=0;j<n;j++)
      {
      cin>>a[i][j];
      }}
            :                                      4           2x2       2


Cin>>a[i][j];
1234
      2   Programming C++ ©by ARAM-CSD
May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX)

 a[j=0]                      a[i=0]
                                                                      a[i=0][j=0]
                                                            j i
                                          <<” “   <<endl   cin>>

cin>>a[i][j]<<endl<<” “;




cin>>a[i][j];

}}

cout<<endl<<” “;



                                                                   cout<<

       for(i=0;i<n;i++)
       {
       for(j=0;j<n;j++)
       {
       cout<<a[i][j]<<” “;
       }
       cout<<endl;
       }



                                      1             2
                                      3             4
                                                     i
                                                                                    j

                                                                             getch();
                                                                                     }



       3   Programming C++ ©by ARAM-CSD
May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX)




//write C++ program to read and print the matrix A3x3 .
#include <iostream.h>
#include <conio.h>
                               Header
                                               123456789

int const n=3;
int a[n][n];              Declaration
int I,j;                                       1    2     3
for(i=0;i<n;i++)                               4    5     6
{
for(j=0;j<n;j++)                               7    8     9
{                             INPUT
cin>>a[i][j];
}}
cout<<endl;

for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout <<a[i][j]<<” “;           OUTPUT
}
cout<<endl;
}

   getch();
   }                       END




         4    Programming C++ ©by ARAM-CSD
May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX)




     1- Write C++ program to read and print out the Matrix A3x3 .then print sum of all rows.
#include <iostream.h>
                                  123456789
#include <conio.h>
int const n=3;
int a[n][n];
int sum[n];                           1 2 3
int i,j;
                                      4     5 6
main()
{                                     7     8 9

for(i=0;i<n;i++)                      Sum of row (1) = 6
{
                                      Sum of row (2) = 15
for(j=0;j<n;j++)
{                                     Sum of row (3) = 24
cin>>a[i][j];
}}
cout<<endl;

for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<a[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
for(i=0;i<n;i++)
{
 sum[i]=0;
for(j=0;j<n;j++)
{
sum[i]=sum[i]+a[i][j];
}
cout<<"Sum of row ("<<(i+1)<<")="<<sum[i]<<endl;
}
getch();
}



         5   Programming C++ ©by ARAM-CSD
May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX)



2-Write C++ program to read and print out the Matrix A3x3 .then print sum of all columns.
#include <iostream.h>
                                  123456789
#include <conio.h>
int const n=3;
int a[n][n];
int sum[n];                           1     2 3
int i,j;
main()                                4     5 6
{
                                      7     8 9
for(i=0;i<n;i++)
                                      Sum of column (1) = 12
{
for(j=0;j<n;j++)
                                      Sum of column (2) = 15
{
cin>>a[i][j];                         Sum of column (3) = 18
}}
cout<<endl;

for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<a[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
for(j=0;j<n;j++)
{
 sum[j]=0;
for(i=0;i<n;i++)
{
sum[j]=sum[j]+a[i][j];
}
cout<<"Sum of column ("<<(j+1)<<")="<<sum[j]<<endl;
}
getch();
}




         6   Programming C++ ©by ARAM-CSD
May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX)




   3-write a program to read and printout Matrix Anxm, then find the sum of each row
   in A and Multiplication of each column in A.
#include <iostream.h>
#include <conio.h>
int const n=3,m=2;
int a[n][m];
int i,j,sum[n],mult[m];
main()
{
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
cin>>a[i][j];
}}
cout<<endl;
cout<<"A1"<<"t"<<"A2"<<endl;
cout<<"___________"<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
cout<<a[i][j]<<"t";
}
cout<<endl;
}
cout<<"____________"<<endl;
for(i=0;i<n;i++)
{ sum[i]=0;
for(j=0;j<m;j++)
{
sum[i]=sum[i]+a[i][j];
}
cout<<"Sum of row ["<<(i+1)<<"]="<<sum[i]<<endl;
}
cout<<"_________________n"<<endl;
for(j=0;j<m;j++)
{ mult[j]=1;
for(i=0;i<n;i++)
{
mult[j]=mult[j]*a[i][j];
}
cout<<"Mult of col ["<<(j+1)<<"]="<<mult[j]<<endl;
}
getch();      7 Programming C++ ©by ARAM-CSD
}
May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX)




 4- Write program to create an array A2x2. first row are EVEN and second row are ODD.
#include <iostream.h>
#include <conio.h>                                          1 2 3 4
int const n=2;
int a[n][n];                                                __      __
int i,j;
main()                                                      1         2
{
for(i=0;i<n;i++)                                            3         4
{
for(j=0;j<n;j++)                                            ___________
{
cin>>a[i][j];
                                                            __      __
}}
cout<<endl;
cout<<"__"<<"t"<<"__"<<endl;
                                                            2         4
for(i=0;i<n;i++)
{
                                                            1         3
for(j=0;j<n;j++)
{
cout<<a[i][j]<<"t";
}
cout<<endl;
}
cout<<"n__________________n";

cout<<"__"<<"t"<<"__"<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(a[i][j]%2==0)
cout<<a[i][j]<<"t";
}}
cout<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(a[i][j]%2==1)
cout<<a[i][j]<<"t";
}}
getch();
}
         8   Programming C++ ©by ARAM-CSD
May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX)



    5-Write C++ program to read and print out the Matrix A3x3 when Diagonal equal to Zero.

#include <iostream.h>
#include <conio.h>
int const n=3;
                                         1 2 3 4 5 6 7 8 9
int a[n][n];
int i,j;                                 0   2       3
main()
{
for(i=0;i<n;i++)                         4   0       6
{
for(j=0;j<n;j++)                         7   8       0
{
cin>>a[i][j];
}}
cout<<endl;

for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i==j)
a[i][j]=0;
}}
cout<<endl;

for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<a[i][j]<<" ";
}
cout<<"nn";
}
getch();
}
      9   Programming C++ ©by ARAM-CSD
May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX)



6-Write C++ program to read and print out the Matrix A3x3 .then print sum of lower triangular.

#include <iostream.h>
#include <conio.h>
                                     1 2 3 4 5 6 7 8 9
int const n=3;
int a[n][n];                         1 2 3
int i,j,l;
main()                               4 5 6
{                                    7 8 9
for(i=0;i<n;i++)
{                                    Sum of Lower Triangular=11
for(j=0;j<n;j++)
{
cin>>a[i][j];
}}
cout<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<a[i][j]<<" ";
}
cout<<"nn";
}
l=0;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i<j)
l=l+a[i][j];
}
}
cout<<"Sum of Lower Triangular="<<l;
getch();
}

      10   Programming C++ ©by ARAM-CSD
May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX)



7- Write C++ program to read and print out the Matrix A3x3 .then print sum of Upper triangular.

#include <iostream.h>
#include <conio.h>
                                              1 2 3 4 5 6 7 8 9
int const n=3;
int a[n][n];                                  1 2       3
int i,j,u;
main()                                        4     5    6
{                                             7     8    9
for(i=0;i<n;i++)
{                                             Sum of Upper Triangular=19
for(j=0;j<n;j++)
{
cin>>a[i][j];
}}
cout<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<a[i][j]<<" ";
}
cout<<"nn";
}
u=0;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i>j)
u=u+a[i][j];
}
}
cout<<"Sum of Upper Triangular="<<l;
getch();
}

      11   Programming C++ ©by ARAM-CSD
May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX)



8- Write C++ program read and print the matrix A3x3, and find the Identity of the matrix.
#include <iostream.h>
#include <conio.h>                          1 2 3 4 5 6 7 8 9
int const n=3;
int a[n][n];
int i,j,k;                                  1 2 3
main()                                      4 5 6
{
                                            7 8 9
for(i=0;i<n;i++)
{                                           The identity of the Matrix
for(j=0;j<n;j++)                            ______________________
{
                                            1 0 0
cin>>a[i][j];
}}                                          0 1 0
cout<<endl;                                 0 0 1
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<a[i][j]<<" ";
}cout<<endl;}
cout<<"nThe Identity of the Matrixn"<<"_____________________n";
k=0;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{if(i==j)
a[i][j]=1;
else
a[i][j]=0;
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{cout<<a[i][j]<<" ";
}cout<<"n";
}
getch();
}


     12   Programming C++ ©by ARAM-CSD
May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX)



9- Write C++ program read and print the matrix A3x3, and find the Trace of the matrix.
#include <iostream.h>
#include <conio.h>                        1 2 3 4 5 6 7 8 9
int const n=3;
int a[n][n];
int i,j,k;                                1 2 3
main()                                    4 5 6
{
                                          7 8 9
for(i=0;i<n;i++)
{                                         The Trace of the Matrix=15
for(j=0;j<n;j++)
{
cin>>a[i][j];
}}
cout<<endl;

for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<a[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;

k=0;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i==j)
{
k=k+a[i][j];
}
}}
cout<<"nThe Trace of the Matrix="<<k;

getch();
}


      13   Programming C++ ©by ARAM-CSD
May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX)

10- Write C++ program read and print the matrix A3x3, and make the lower triangular=0.
 #include <iostream.h>
 #include <conio.h>                      1 2 3 4 5 6 7 8 9
 int const n=3;
 int a[n][n];
                                         1 2 3
 int i,j;
 main()                                  4 5 6
 {                                       7 8 9
 for(i=0;i<n;i++)
 {
 for(j=0;j<n;j++)                        1   0   0
 {                                       4   5   0
 cin>>a[i][j];
                                         7   8   9
 }}
 cout<<endl;
 for(i=0;i<n;i++)
 {
 for(j=0;j<n;j++)
 {
 cout<<a[i][j]<<" ";
 }cout<<endl;}
 cout<<endl;
 for(i=0;i<n;i++)
 {
 for(j=0;j<n;j++)
 {if(i<j)
 a[i][j]=0;
 cout<<a[i][j]<<” “;
 }
 cout<<endl;
 }
 getch();
 }




     14   Programming C++ ©by ARAM-CSD
May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX)

11- Write C++ program read and print the matrix A3x3, then check whether is symmetric or
not.
 #include <iostream.h>
 #include <conio.h>                      1 2 3 4 5 6 7 8 9
 int const n=3;
 int a[n][n];
 int i,j,k;                              1 2 3
 main()                                  4 5 6
 {
                                         7 8 9
 for(i=0;i<n;i++)
 {                                       The Matrix is not symmetric
 for(j=0;j<n;j++)
 {
 cin>>a[i][j];
 }}
 cout<<endl;
 for(i=0;i<n;i++)
 {
 for(j=0;j<n;j++)
                                         1 2 3 2 5 6 3 6 9
 {
 cout<<a[i][j]<<" ";
 }cout<<endl;}                           1 2 3
 cout<<endl;
                                         2 5 6
 k=0;
 for(i=0;i<n;i++)                        3 6 9
 {                                       The Matrix is symmetric
 for(j=0;j<n;j++)
 {if(a[i][j]==a[i][j])
 k=k+1;
 }}
 if(k==n*n)
 cout<<”The Matrix is symmetric”;
 else
 cout<<”The Matrix is not symmetric”;
 getch();
 }




     15   Programming C++ ©by ARAM-CSD
May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX)

12- Write C++ program read and print the matrix A3x3, and make the Upper triangular=0.
#include <iostream.h>
#include <conio.h>
                                         1 2 3 4 5 6 7 8 9
int const n=3;
int a[n][n];                             1 2 3
int i,j;
main()
                                         4 5 6
{                                        7 8 9
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
                                         1   2   3
{                                        0   5   6
cin>>a[i][j];                            0   0   9
}}
cout<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<a[i][j]<<" ";
}cout<<endl;}
cout<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{if(i>j)
a[i][j]=0;
cout<<a[i][j]<<” “;
}
cout<<endl;
}
getch();
}




     16   Programming C++ ©by ARAM-CSD

Contenu connexe

Tendances

Image Cryptography and Steganography
Image Cryptography and SteganographyImage Cryptography and Steganography
Image Cryptography and Steganography
Mohammad Amin Amjadi
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacion
Jeff Tu Pechito
 
The International Journal of Engineering and Science
The International Journal of Engineering and ScienceThe International Journal of Engineering and Science
The International Journal of Engineering and Science
theijes
 
Cn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshanCn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshan
riturajj
 
Datastructure tree
Datastructure treeDatastructure tree
Datastructure tree
rantd
 

Tendances (19)

Computer Practical XII
Computer Practical XIIComputer Practical XII
Computer Practical XII
 
C Code and the Art of Obfuscation
C Code and the Art of ObfuscationC Code and the Art of Obfuscation
C Code and the Art of Obfuscation
 
662305 LAB13
662305 LAB13662305 LAB13
662305 LAB13
 
PRACTICAL COMPUTING
PRACTICAL COMPUTINGPRACTICAL COMPUTING
PRACTICAL COMPUTING
 
Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”Rainer Grimm, “Functional Programming in C++11”
Rainer Grimm, “Functional Programming in C++11”
 
Image Cryptography and Steganography
Image Cryptography and SteganographyImage Cryptography and Steganography
Image Cryptography and Steganography
 
Monad
MonadMonad
Monad
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacion
 
Class list data structure
Class list data structureClass list data structure
Class list data structure
 
Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”Bartosz Milewski, “Re-discovering Monads in C++”
Bartosz Milewski, “Re-discovering Monads in C++”
 
The International Journal of Engineering and Science
The International Journal of Engineering and ScienceThe International Journal of Engineering and Science
The International Journal of Engineering and Science
 
Container adapters
Container adaptersContainer adapters
Container adapters
 
2020 1학기 정기스터디 2주차
2020 1학기 정기스터디 2주차2020 1학기 정기스터디 2주차
2020 1학기 정기스터디 2주차
 
CS253: Minimum spanning Trees (2019)
CS253: Minimum spanning Trees (2019)CS253: Minimum spanning Trees (2019)
CS253: Minimum spanning Trees (2019)
 
Cn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshanCn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshan
 
Yoyak ScalaDays 2015
Yoyak ScalaDays 2015Yoyak ScalaDays 2015
Yoyak ScalaDays 2015
 
Datastructure tree
Datastructure treeDatastructure tree
Datastructure tree
 
Низкоуровневые оптимизации .NET-приложений
Низкоуровневые оптимизации .NET-приложенийНизкоуровневые оптимизации .NET-приложений
Низкоуровневые оптимизации .NET-приложений
 
An Introduction to Coding Theory
An Introduction to Coding TheoryAn Introduction to Coding Theory
An Introduction to Coding Theory
 

Similaire à ماترێکس به‌ کوردی ئارام

Programa.eje
Programa.ejePrograma.eje
Programa.eje
guapi387
 
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
AAKASH KUMAR
 
OOP 2012 - Hint: Dynamic allocation in c++
OOP 2012 - Hint: Dynamic allocation in c++OOP 2012 - Hint: Dynamic allocation in c++
OOP 2012 - Hint: Dynamic allocation in c++
Allan Sun
 
C Prog - Pointers
C Prog - PointersC Prog - Pointers
C Prog - Pointers
vinay arora
 

Similaire à ماترێکس به‌ کوردی ئارام (20)

Computer Programming- Lecture 9
Computer Programming- Lecture 9Computer Programming- Lecture 9
Computer Programming- Lecture 9
 
Programa.eje
Programa.ejePrograma.eje
Programa.eje
 
PPS Arrays Matrix operations
PPS Arrays Matrix operationsPPS Arrays Matrix operations
PPS Arrays Matrix operations
 
array2d.ppt
array2d.pptarray2d.ppt
array2d.ppt
 
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
2 d array(part 1) || 2D ARRAY FUNCTION WRITING || GET 100% MARKS IN CBSE CS
 
OOP 2012 - Hint: Dynamic allocation in c++
OOP 2012 - Hint: Dynamic allocation in c++OOP 2012 - Hint: Dynamic allocation in c++
OOP 2012 - Hint: Dynamic allocation in c++
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
 
Arrays
ArraysArrays
Arrays
 
Write Python for Speed
Write Python for SpeedWrite Python for Speed
Write Python for Speed
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1
 
Vcs16
Vcs16Vcs16
Vcs16
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
C lab excellent
C lab excellentC lab excellent
C lab excellent
 
C and Data Structures Lab Solutions
C and Data Structures Lab SolutionsC and Data Structures Lab Solutions
C and Data Structures Lab Solutions
 
C and Data Structures
C and Data Structures C and Data Structures
C and Data Structures
 
C programs
C programsC programs
C programs
 
ParallelProgrammingBasics_v2.pdf
ParallelProgrammingBasics_v2.pdfParallelProgrammingBasics_v2.pdf
ParallelProgrammingBasics_v2.pdf
 
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
 
Introduction to cpp (c++)
Introduction to cpp (c++)Introduction to cpp (c++)
Introduction to cpp (c++)
 
C Prog - Pointers
C Prog - PointersC Prog - Pointers
C Prog - Pointers
 

Dernier

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 

Dernier (20)

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 

ماترێکس به‌ کوردی ئارام

  • 1. May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX) Type array [size1][size2]; Row A[ i ][ j ] Column #include <iostream.h> #include <conio.h> #include <math.h> #include <cstring.h> 1. int 2. float 3. string 4. char Int const size1=?,size2=?; 1 Programming C++ ©by ARAM-CSD
  • 2. May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX) x x x x Int array[size1][size2]; int i,j; i,j,n,k,l,m, main() { cin, cout,if, for(i=0;i<size1;i++) { for(j=0;j<size2;j++) { _____ _____ }} size1 i size1 size2 j size2 n=2 A2x2 cin>> for(i=0;i<n;i++) { for(j=0;j<n;j++) { cin>>a[i][j]; }} : 4 2x2 2 Cin>>a[i][j]; 1234 2 Programming C++ ©by ARAM-CSD
  • 3. May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX) a[j=0] a[i=0] a[i=0][j=0] j i <<” “ <<endl cin>> cin>>a[i][j]<<endl<<” “; cin>>a[i][j]; }} cout<<endl<<” “; cout<< for(i=0;i<n;i++) { for(j=0;j<n;j++) { cout<<a[i][j]<<” “; } cout<<endl; } 1 2 3 4 i j getch(); } 3 Programming C++ ©by ARAM-CSD
  • 4. May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX) //write C++ program to read and print the matrix A3x3 . #include <iostream.h> #include <conio.h> Header 123456789 int const n=3; int a[n][n]; Declaration int I,j; 1 2 3 for(i=0;i<n;i++) 4 5 6 { for(j=0;j<n;j++) 7 8 9 { INPUT cin>>a[i][j]; }} cout<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) { cout <<a[i][j]<<” “; OUTPUT } cout<<endl; } getch(); } END 4 Programming C++ ©by ARAM-CSD
  • 5. May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX) 1- Write C++ program to read and print out the Matrix A3x3 .then print sum of all rows. #include <iostream.h> 123456789 #include <conio.h> int const n=3; int a[n][n]; int sum[n]; 1 2 3 int i,j; 4 5 6 main() { 7 8 9 for(i=0;i<n;i++) Sum of row (1) = 6 { Sum of row (2) = 15 for(j=0;j<n;j++) { Sum of row (3) = 24 cin>>a[i][j]; }} cout<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) { cout<<a[i][j]<<" "; } cout<<endl; } cout<<endl; for(i=0;i<n;i++) { sum[i]=0; for(j=0;j<n;j++) { sum[i]=sum[i]+a[i][j]; } cout<<"Sum of row ("<<(i+1)<<")="<<sum[i]<<endl; } getch(); } 5 Programming C++ ©by ARAM-CSD
  • 6. May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX) 2-Write C++ program to read and print out the Matrix A3x3 .then print sum of all columns. #include <iostream.h> 123456789 #include <conio.h> int const n=3; int a[n][n]; int sum[n]; 1 2 3 int i,j; main() 4 5 6 { 7 8 9 for(i=0;i<n;i++) Sum of column (1) = 12 { for(j=0;j<n;j++) Sum of column (2) = 15 { cin>>a[i][j]; Sum of column (3) = 18 }} cout<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) { cout<<a[i][j]<<" "; } cout<<endl; } cout<<endl; for(j=0;j<n;j++) { sum[j]=0; for(i=0;i<n;i++) { sum[j]=sum[j]+a[i][j]; } cout<<"Sum of column ("<<(j+1)<<")="<<sum[j]<<endl; } getch(); } 6 Programming C++ ©by ARAM-CSD
  • 7. May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX) 3-write a program to read and printout Matrix Anxm, then find the sum of each row in A and Multiplication of each column in A. #include <iostream.h> #include <conio.h> int const n=3,m=2; int a[n][m]; int i,j,sum[n],mult[m]; main() { for(i=0;i<n;i++) { for(j=0;j<m;j++) { cin>>a[i][j]; }} cout<<endl; cout<<"A1"<<"t"<<"A2"<<endl; cout<<"___________"<<endl; for(i=0;i<n;i++) { for(j=0;j<m;j++) { cout<<a[i][j]<<"t"; } cout<<endl; } cout<<"____________"<<endl; for(i=0;i<n;i++) { sum[i]=0; for(j=0;j<m;j++) { sum[i]=sum[i]+a[i][j]; } cout<<"Sum of row ["<<(i+1)<<"]="<<sum[i]<<endl; } cout<<"_________________n"<<endl; for(j=0;j<m;j++) { mult[j]=1; for(i=0;i<n;i++) { mult[j]=mult[j]*a[i][j]; } cout<<"Mult of col ["<<(j+1)<<"]="<<mult[j]<<endl; } getch(); 7 Programming C++ ©by ARAM-CSD }
  • 8. May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX) 4- Write program to create an array A2x2. first row are EVEN and second row are ODD. #include <iostream.h> #include <conio.h> 1 2 3 4 int const n=2; int a[n][n]; __ __ int i,j; main() 1 2 { for(i=0;i<n;i++) 3 4 { for(j=0;j<n;j++) ___________ { cin>>a[i][j]; __ __ }} cout<<endl; cout<<"__"<<"t"<<"__"<<endl; 2 4 for(i=0;i<n;i++) { 1 3 for(j=0;j<n;j++) { cout<<a[i][j]<<"t"; } cout<<endl; } cout<<"n__________________n"; cout<<"__"<<"t"<<"__"<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(a[i][j]%2==0) cout<<a[i][j]<<"t"; }} cout<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(a[i][j]%2==1) cout<<a[i][j]<<"t"; }} getch(); } 8 Programming C++ ©by ARAM-CSD
  • 9. May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX) 5-Write C++ program to read and print out the Matrix A3x3 when Diagonal equal to Zero. #include <iostream.h> #include <conio.h> int const n=3; 1 2 3 4 5 6 7 8 9 int a[n][n]; int i,j; 0 2 3 main() { for(i=0;i<n;i++) 4 0 6 { for(j=0;j<n;j++) 7 8 0 { cin>>a[i][j]; }} cout<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(i==j) a[i][j]=0; }} cout<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) { cout<<a[i][j]<<" "; } cout<<"nn"; } getch(); } 9 Programming C++ ©by ARAM-CSD
  • 10. May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX) 6-Write C++ program to read and print out the Matrix A3x3 .then print sum of lower triangular. #include <iostream.h> #include <conio.h> 1 2 3 4 5 6 7 8 9 int const n=3; int a[n][n]; 1 2 3 int i,j,l; main() 4 5 6 { 7 8 9 for(i=0;i<n;i++) { Sum of Lower Triangular=11 for(j=0;j<n;j++) { cin>>a[i][j]; }} cout<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) { cout<<a[i][j]<<" "; } cout<<"nn"; } l=0; for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(i<j) l=l+a[i][j]; } } cout<<"Sum of Lower Triangular="<<l; getch(); } 10 Programming C++ ©by ARAM-CSD
  • 11. May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX) 7- Write C++ program to read and print out the Matrix A3x3 .then print sum of Upper triangular. #include <iostream.h> #include <conio.h> 1 2 3 4 5 6 7 8 9 int const n=3; int a[n][n]; 1 2 3 int i,j,u; main() 4 5 6 { 7 8 9 for(i=0;i<n;i++) { Sum of Upper Triangular=19 for(j=0;j<n;j++) { cin>>a[i][j]; }} cout<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) { cout<<a[i][j]<<" "; } cout<<"nn"; } u=0; for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(i>j) u=u+a[i][j]; } } cout<<"Sum of Upper Triangular="<<l; getch(); } 11 Programming C++ ©by ARAM-CSD
  • 12. May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX) 8- Write C++ program read and print the matrix A3x3, and find the Identity of the matrix. #include <iostream.h> #include <conio.h> 1 2 3 4 5 6 7 8 9 int const n=3; int a[n][n]; int i,j,k; 1 2 3 main() 4 5 6 { 7 8 9 for(i=0;i<n;i++) { The identity of the Matrix for(j=0;j<n;j++) ______________________ { 1 0 0 cin>>a[i][j]; }} 0 1 0 cout<<endl; 0 0 1 for(i=0;i<n;i++) { for(j=0;j<n;j++) { cout<<a[i][j]<<" "; }cout<<endl;} cout<<"nThe Identity of the Matrixn"<<"_____________________n"; k=0; for(i=0;i<n;i++) { for(j=0;j<n;j++) {if(i==j) a[i][j]=1; else a[i][j]=0; } } for(i=0;i<n;i++) { for(j=0;j<n;j++) {cout<<a[i][j]<<" "; }cout<<"n"; } getch(); } 12 Programming C++ ©by ARAM-CSD
  • 13. May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX) 9- Write C++ program read and print the matrix A3x3, and find the Trace of the matrix. #include <iostream.h> #include <conio.h> 1 2 3 4 5 6 7 8 9 int const n=3; int a[n][n]; int i,j,k; 1 2 3 main() 4 5 6 { 7 8 9 for(i=0;i<n;i++) { The Trace of the Matrix=15 for(j=0;j<n;j++) { cin>>a[i][j]; }} cout<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) { cout<<a[i][j]<<" "; } cout<<endl; } cout<<endl; k=0; for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(i==j) { k=k+a[i][j]; } }} cout<<"nThe Trace of the Matrix="<<k; getch(); } 13 Programming C++ ©by ARAM-CSD
  • 14. May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX) 10- Write C++ program read and print the matrix A3x3, and make the lower triangular=0. #include <iostream.h> #include <conio.h> 1 2 3 4 5 6 7 8 9 int const n=3; int a[n][n]; 1 2 3 int i,j; main() 4 5 6 { 7 8 9 for(i=0;i<n;i++) { for(j=0;j<n;j++) 1 0 0 { 4 5 0 cin>>a[i][j]; 7 8 9 }} cout<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) { cout<<a[i][j]<<" "; }cout<<endl;} cout<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) {if(i<j) a[i][j]=0; cout<<a[i][j]<<” “; } cout<<endl; } getch(); } 14 Programming C++ ©by ARAM-CSD
  • 15. May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX) 11- Write C++ program read and print the matrix A3x3, then check whether is symmetric or not. #include <iostream.h> #include <conio.h> 1 2 3 4 5 6 7 8 9 int const n=3; int a[n][n]; int i,j,k; 1 2 3 main() 4 5 6 { 7 8 9 for(i=0;i<n;i++) { The Matrix is not symmetric for(j=0;j<n;j++) { cin>>a[i][j]; }} cout<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) 1 2 3 2 5 6 3 6 9 { cout<<a[i][j]<<" "; }cout<<endl;} 1 2 3 cout<<endl; 2 5 6 k=0; for(i=0;i<n;i++) 3 6 9 { The Matrix is symmetric for(j=0;j<n;j++) {if(a[i][j]==a[i][j]) k=k+1; }} if(k==n*n) cout<<”The Matrix is symmetric”; else cout<<”The Matrix is not symmetric”; getch(); } 15 Programming C++ ©by ARAM-CSD
  • 16. May 13, 2012 TWO-DIMENSIONAL ARRAYS (MATRIX) 12- Write C++ program read and print the matrix A3x3, and make the Upper triangular=0. #include <iostream.h> #include <conio.h> 1 2 3 4 5 6 7 8 9 int const n=3; int a[n][n]; 1 2 3 int i,j; main() 4 5 6 { 7 8 9 for(i=0;i<n;i++) { for(j=0;j<n;j++) 1 2 3 { 0 5 6 cin>>a[i][j]; 0 0 9 }} cout<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) { cout<<a[i][j]<<" "; }cout<<endl;} cout<<endl; for(i=0;i<n;i++) { for(j=0;j<n;j++) {if(i>j) a[i][j]=0; cout<<a[i][j]<<” “; } cout<<endl; } getch(); } 16 Programming C++ ©by ARAM-CSD