C program to print R diagonal triangle:
#define rows 3
#define cols 3
void main()
{
int i=0,j=0;
int arr[rows][cols];
for (i=0; i<=rows-1; i++)
for(j=0;j<=cols-1;j++)
{
printf("Enter elements (%d,%d)\n",(i+1),(j+1));
scanf("%d",&arr[i][j]);
}
for (i=0; i<=rows-1; i++)
{
printf("\t");
for(j=0;j<3;j++)
{
printf("%d ",arr[i][j]);
}
printf("\n");
}
printf("\n Revers of matrix\n");
for(i=0;i<=rows-1;i++)
{
printf("\t");
for(j=0;j<=cols-1;j++)
{
if(i+j==2)
printf("%d ",arr[i][j]);
else
printf(" ");
}
printf("\n");
}
}