//Upper left triangle
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,size;
int array[10][10];
printf("Enter the size of the array:");
scanf("%d", &size);
printf("\n Enter the array elements:");
for(i=0;i<size;i++){
for(j=0;j<size;j++){
scanf("%d",&array[i][j]);
}
}
printf("\n Matrix:\n");
for(i=0;i<size;i++){
for(j=0;j<size;j++){
printf("%d ", array[i][j]);
}
printf("\n");
}
for(i=0;i<size;i++){
for(j=0;j<size;j++){
if((i+j)<=(size-1)){
printf("%d", array[i][j]);
}
printf(" ");
}
printf("\n");
}
getch();
return 0;
}
Output:
Enter the size of the array:3
Enter the array elements:1 2 3 4 5 6 7 8 9
Matrix:
1 2 3
4 5 6
7 8 9
1 2 3
4 5
7
#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,size;
int array[10][10];
printf("Enter the size of the array:");
scanf("%d", &size);
printf("\n Enter the array elements:");
for(i=0;i<size;i++){
for(j=0;j<size;j++){
scanf("%d",&array[i][j]);
}
}
printf("\n Matrix:\n");
for(i=0;i<size;i++){
for(j=0;j<size;j++){
printf("%d ", array[i][j]);
}
printf("\n");
}
for(i=0;i<size;i++){
for(j=0;j<size;j++){
if((i+j)<=(size-1)){
printf("%d", array[i][j]);
}
printf(" ");
}
printf("\n");
}
getch();
return 0;
}
Output:
Enter the size of the array:3
Enter the array elements:1 2 3 4 5 6 7 8 9
Matrix:
1 2 3
4 5 6
7 8 9
1 2 3
4 5
7
Mention post title...
ReplyDelete