Monday, 18 May 2015

Write a program in c++ to input the value in two dimensional array and print all the elements in matrix form.

Coding:- 

                         

#include<iostream.h>

void main()

{
 int a[2][4];

 int i,j;

 cout<<"enter values in an array  \n";
 for(i=0;i<=1;i++)
 {

for(j=0;j<=2;j++)
cin>>a[i][j];


 }
         cout<<"the array is : \n";

     for(i=0;i<=1;i++)
 {

for(j=0;j<=2;j++)
 cout<<"  "<<a[i][j];

 cout<<"\n";


 }
}

Output:- 

                   

No comments:

Post a Comment