-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathQ4_Upper_Triangular.c
More file actions
55 lines (42 loc) · 872 Bytes
/
Q4_Upper_Triangular.c
File metadata and controls
55 lines (42 loc) · 872 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
//Name :- Anand Patel Reg. No.:-AM.EN.U4CSE19206 Batch:- S2-CSE
#include<stdio.h>
int uppertri(int arr[100][100],int,int);
int main()
{
int arr[100][100]; //initializing the 2D-Array
int r,c,i,j;
printf("Enter the number of rows: "); //enter number of rows of 2D-Array
scanf("%d",&r);
printf("\n");
printf("Enter the number of columns : "); //enter number of columns of 2D-Array
scanf("%d",&c);
printf("\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
scanf("%d",&arr[i][j]);
}
int s=uppertri(arr,r,c); //calling function
if(s>=100)
printf("YES\n");
else
printf("NO\n");
}
int uppertri(int arr[100][100],int r,int c) //declaring function
{
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
if(i>j)
arr[i][j]=0;
}
}
int sum=0;
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
sum+=arr[i][j];
}
return sum;
}