You are on page 1of 1

// rotating clockwise direction

#include <iostream>

using namespace std;

int main()
{
int i,j, a[10][10],m,n,row=0,col=0;
cout<<"enter the number of rows and column"<<endl;
cin>>m>>n;
cout<<"Enter the element:"<<endl;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cin>>a[i][j];
}
}
// print the matrix in spinal order
cout<<"print the matrix :"<<endl;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<a[i][j]<<"\t";
}
cout<<endl;

}
if(row<m && col<n)
{
cout<<"Print the matrix after rotating 90 degree clock
wise:"<<endl;
for(j=row;j<n;j++)
{
for(i=m-1;i>=0;i--)
{
cout<<a[i][j]<<"\t";
}
cout<<endl;
}
}

You might also like