Wednesday, 23 April 2014

17. Write a program print the upper and lower triangle of the matrix.



#include<stdio.h>
#include<conio.h>
void main()
{
          int arr[3][3],i,j,k=2;
          clrscr();
          for(i=0; i<3; i++)
          {
                   for(j=0; j<3; j++)
                   {
                             printf("\tEnter value -> ");
                             scanf("%d",&arr[i][j]);
                   }
          }
          printf("\n\n");
          for(i=0; i<3; i++)
          {
                   for(j=0; j<=2; j++)
                   {
                             if(arr[i]==arr[k])
                             {
                             printf("\t-");
                             k--;
                             }
                             else
                             {
                             printf("\t%d",arr[i][j]);
                             k--;
                             }
                    }
                   printf("\n\n");
                   k=2;
          }
          getch();
          }

No comments:

Post a Comment