Professional Documents
Culture Documents
Cout "How Many Number You Want To Input This Program/n"
Cout "How Many Number You Want To Input This Program/n"
Solution:
#include"bits/stdc++.h"
using namespace std;
int main()
{
int n,a,temp,swip;
cout<<"How many number you want to input this program\n";
cin>>n;
int Arr[n+2];
Arr[n]=temp;
for(a=n;a>=1;a--)
{
if(temp<Arr[a-1])
{
Arr[a+1]=Arr[a];
}
else
{
Arr[a++]=temp;
break;
}
}
return 0;
}
Output:
Question: Delete one an array element .
Solved:
#include"bits/stdc++.h"
using namespace std;
int main()
{
int n,a,temp;
cout<<"How many number you want to input this program\n";
cin>>n;
int Arr[n];
cout<<"In this Array which element you want to Delete .Just input the
serial number\n";
cin>>temp;
for(a=temp-1;a<n;a++)
{
Arr[a]=Arr[a+1];
}
Arr[n-1];
int Arr[n+1][n+1];
cout<<"So,now input the Matrix element in this program\n";
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
cout<<"["<<i<<"]["<<j<<"]=";
cin>>Arr[i][j];
if(i==1 || i==n)
sum+=Arr[i][j];
cout<<endl;
}
cout<<"Matrix:\n";
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
//cout<<"["<<i<<"]["<<j<<"]=";
cout<<Arr[i][j]<<" ";
}
cout<<endl;
}
return 0;
}
Output:
int Arr[n+1][n+1];
cout<<endl;
}
cout<<"Matrix:\n";
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
//cout<<"["<<i<<"]["<<j<<"]=";
cout<<Arr[i][j]<<" ";
}
cout<<endl;
}
cout<<"Now,the sum of Matrix of diagonal element of two dimensional
="<<sum<<endl;
return 0;
}
Output:
#include"bits/stdc++.h"
using namespace std;
int main()
{
int n,i,j,tem;
cout<<"Input the 1st Array element number\n"<<endl;
cin>>n;
int Arr[n];
for(i=0;i<n;i++)
{
cin>>Arr[i];
int Brr[n];
Arr[i+n];
for(j=0;j<n;j++)
{
cin>>Brr[j];
Arr[j+i]=Brr[j];
}
n=i+n;
for(j=0;j<n;j++)
{
for(i=j+1;i<n;i++)
{
if(Arr[j]<Arr[i])
{
tem=Arr[j];
Arr[j]=Arr[i];
Arr[i]=tem;
}
}
return 0;
}
Output: