View Code of Problem 51

#include <stdio.h>
#include <stdlib.h>
     
    /* run this program using the console pauser or add your own getch, system("pause") or input loop */
     
    int main(int argc, char *argv[]) {
    	int n;
    	int i;
    	int j;
    	int a[n][n];
    	int sum;
    	scanf("%d",&n);
    	for(i=0;i<n;i++){
    		for(j=0;j<n;j++){
    			scanf("%d",&a[i][j]);
			}
			
		}
		
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				if(i>=j){
			    sum=sum+a[i][j];
	       }
	    }
	       
		}

		printf("%d",sum);
    	return 0;
    }

Double click to view unformatted code.


Back to problem 51