Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class LowerTriangle
- {
- static int add(int a[][],int r,int c)
- {
- int i,j,totalsum=0;
- for(i=0;i<r;i++)
- {
- for(j=0;j<c;j++)
- {
- if(j<i)
- {
- totalsum=totalsum+a[i][j];
- }
- }
- }
- return totalsum;
- }
- public static void main(String args[])
- {
- Scanner s=new Scanner(System.in);
- int r,c,lower_sum=0;
- System.out.println("Enter No of Rows and Columns");
- r=s.nextInt();
- c=s.nextInt();
- int a[][]=new int[100][100];
- for(int i=0;i<r;i++)
- {
- for(int j=0;j<c;j++)
- {
- a[i][j]=s.nextInt();
- }
- }
- lower_sum=add(a,r,c);
- System.out.println("Sum of Lower Triangle Matrix is:"+lower_sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement