-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathProgram15.cpp
69 lines (69 loc) · 1.07 KB
/
Program15.cpp
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
62
63
64
65
66
67
68
69
#include<conio.h>
#include<iostream.h>
void sum(int A[10][10] ,int N )
{
int i,j,sum=0;
for(i=0;i<N;i++)
for(j=0;j<N;j++)
{
if(i>j||j>i)
sum+=A[i][j];
}
cout<<"sum="<<sum;
}
void prod(int A[10][10], int N )
{
int i,j,pro=1;
for(i=0;i<N;i++)
for(j=0;j<N;j++)
{
if(i==j||i+j==N-1)
pro*=A[i][j];
}
cout<<"\nproduct="<<pro;
}
void trans(int A[10][10] ,int N)
{
int i,j,b[10][10];
for(i=0;i<N;i++)
for(j=0;j<N;j++)
{
b[i][j]=A[j][i];
}
for(i=0;i<N;i++)
{
cout<<"\n";
for(j=0;j<N;j++)
cout<<b[i][j]<<" ";
}
}
void main()
{
clrscr();
int ch,i,j,N,A[10][10];
char y;
while(y=='y'||y=='Y')
{
cout<<"\nEnter N";
cin>>N;
for(i=0;i<N;i++)
for(j=0;j<N;j++)
{
cout<<"enter element";
cin>>A[i][j];
}
cout<<"Menu \n1 Sum of upper and lower diagonal elements \n2 Product of diagonal elements\n3 transpose and display ";
cin>>ch;
if(ch==1)
sum(A,N);
else if(ch==2)
prod(A,N);
else if(ch==3)
trans(A,N);
else
cout<<"invalid choice";
cout<<"\nDo you want to continue?";
cin>>y;
}
getch();
}