insertion in Matrix how to add value in specif location in 2d array, insertion in 2d array matrix program in C++
Insertion in Matrix's(ARRAY) | Array programs in C++
This is C++ program to insert element in specific location in multi dimensional matrix's which accepts input from user and also ask to tell place where he want to enter element in array.
insertion in arrays
 insertion in arrays of c
 insertion sort in arrays
 insertion sort in arrays c++
 insertion and deletion in arrays
 algorithm of insertion in arrays


Program to insert element in array


#include "stdafx.h"
#include "iostream"
#include "conio.h"
using namespace std;
int main()
{
int a[4][4]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}};
int row,coulmn,j,i,number,check=3;

cout<<"matrix elements are== ";
for(int i=0;i<4;i++)
{
cout<<endl;
for(int j=0;j<4;j++)
{
cout<<a[i][j]<<"\t";
}
}

cout<<"\n\n"<<"Enter row== ";
cin>>row;
cout<<"\n\n"<<"Enter coulmn== ";
cin>>coulmn;
cout<<"\n\n"<<"Enter value== ";
cin>>number;
for( i=0;i<=row;i++)
{ if(i==row)
check=coulmn-1;
for( j=0;j<=check;j++)
{
a[i][j]=a[i][j+1];
}
}
a[row][coulmn]=number;
cout<<endl<<"after adding element matrix is== "<<endl;
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
cout<<a[i][j];
cout<<"\t";
}
cout<<"\n";
}

0 comments:

Post a Comment

 
Top