fork download
  1. #include<stdio.h>
  2.  
  3. int main() {
  4. int i, j,rows,columns;
  5. int a[5][5] = {
  6. {1,2,3,4,5},
  7. {6,7,8,9,10},
  8. {11,12,13,14,15},
  9. {16,17,18,19,20},
  10. {21,22,23,24,25}
  11. };
  12. rows = 5;
  13. columns= 5;
  14.  
  15.  
  16.  
  17. //Print triangle elements
  18. printf("Print upper triangle elements ");
  19. for (i = 0; i < 5; i++)
  20. for (j = 0; j < 5; j++) {
  21. // Condition for Upper Triangle
  22. if (i < j) {
  23. printf("%d ", a[i][j]);
  24. }
  25. }
  26.  
  27. return (0);
  28. }
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
Print upper triangle elements 2 3 4 5 8 9 10 14 15 20