Search
 
SCRIPT & CODE EXAMPLE
 

C

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 : 
");
    for(i = 0; i < 3; i++){
        for(j = 0; j < 3; j++){
            printf("Matrix[%d][%d]: 
",i,j);
            scanf("%d",&a[i][j]);
        }
    }

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

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



    return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: c michael 
C :: Odd-Even-inator with function in C 
C :: wait system call 
C :: send array to child process c 
C :: panagram in c 
C :: return multiple values using the call by reference 
C :: golang inline function definition 
C :: levenshtein c 
C :: putting character in the begginig and end of sring C 
C :: attiny pinout 
C :: online c compiler with mpi 
C :: navigate to line intellij 
C :: programmation c 
C :: changing an item in an array in c 
C :: what is implicit typecasting 
C :: how to push node using linked list c 
C :: latex font sizes 
Dart :: flutter column center horizontal text 
Dart :: flutter clear navigation stack 
Dart :: how to get whatsapp groups in app flutter programmatically 
Dart :: flutter card border radius overflow hidden 
Dart :: flutter array of strings 
Dart :: flutter types class enum 
Dart :: flutter checkbox color 
Dart :: get file type from file path flutter 
Dart :: flutter check ios or android 
Dart :: flutter flotingactionbutton with text 
Dart :: remove object key dart 
Dart :: dart compare two lists 
Dart :: flutter add value to list<map<string, int 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =