Horje
Sum of upper & lower triangles elements Code Example
Sum of upper & lower triangles elements
#include <stdio.h>

int main()
{

    int a[3][3],i,j,upper_sum=0,lower_sum=0;
    printf("Enter elements for the matrix : \n");
    for(i = 0; i < 3; i++){
        for(j = 0; j < 3; j++){
            printf("Matrix[%d][%d]: \n",i,j);
            scanf("%d",&a[i][j]);
        }
    }

    printf("The Matrix: \n");
    for(i = 0; i < 3; i++){
        for(j = 0; j < 3; j++){
            
            printf("%d ",a[i][j]);
        }
        printf("\n");
    }

    printf("Getting sum... \n");
    for(i = 0; i < 3; i++){
        for(j = 0; j < 3; j++){
            if(i < j){
                printf("The Upper Triangle elements are %d\n",a[i][j]);
                upper_sum+=a[i][j];
            }
            if(i > j){
                printf("The lower Triangle elements are %d\n",a[i][j]);
                lower_sum+=a[i][j];
            }
            
            
        }
       
    }
    
    printf("Sum of Uppper triangles are : %d\n",upper_sum);
    printf("Sum of lower triangles are : %d\n",lower_sum);



    return 0;
}




C

Related
c program for airthmetic operators Code Example c program for airthmetic operators Code Example
worst case Code Example worst case Code Example
terraform fargate cpu Code Example terraform fargate cpu Code Example
Redis Service Code Example Redis Service Code Example
bullseye lxc network problem Code Example bullseye lxc network problem Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10