-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLWRK2.C
More file actions
61 lines (61 loc) · 1000 Bytes
/
LWRK2.C
File metadata and controls
61 lines (61 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*Write an interactive program in C to print the upper and
lower triangle of the matrix.*/
#include<stdio.h>
#include<conio.h>
#define max 10
void main()
{
int mat[max][max],i,j,n,ch;
clrscr();
printf("Enter the order of the square matrix:\t");
scanf("%d",&n);
printf("Enter the elements of the matrix\n");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&mat[i][j]);
clrscr();
printf("\t\t\tTOP MENU\n\n");
printf("1.Upper Matrix\n");
printf("2.Lower Matrix\n");
printf("Enter your choice:\t");
scanf("%d",&ch);
clrscr();
switch(ch)
{
case 1:
printf("Upper Matrix\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i<=j)
{
printf("%d\t",mat[i][j]);
}
else
{
printf("\t");
}
}
printf("\n");
}
break;
case 2:
printf("Lower Matrix\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i>=j)
{
printf("%d\t",mat[i][j]);
}
}
printf("\n");
}
break;
default:
printf("Wrong Entry");
}
getch();
}