Advertisement
Shailrshah

5x5 Matrix

Apr 18th, 2013
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. int i,j, a[10][10],count,choice;
  3.  
  4. void one()
  5. {
  6.    
  7.     for(i=0;i<5-1;i++)
  8.     {
  9.         for (j=0; j<4-i; j++)
  10.         {
  11.             a[i][j]=1;
  12.         }
  13.     }
  14.    
  15. }
  16.  
  17. void two()
  18. {
  19.     for (i=0; i<5; i++)
  20.     {
  21.         for (j=0; j<5; j++)
  22.         {
  23.             if(a[i][j]!= 1)
  24.                 a[i][j] = -1;
  25.         }
  26.     }
  27.  
  28. }
  29.  
  30. void three()
  31. {
  32.     count = 4;
  33.     for(i=0;i<5;i++)
  34.     {
  35.         a[i][count]=0;
  36.         count--;
  37.     }
  38. }
  39. int main()
  40. {
  41.     one();
  42.     two();
  43.     three();
  44.    
  45.     printf("The matrix is:-\n");
  46.     for (i = 0; i<5; i++)
  47.     {
  48.         for (j=0; j<5; j++)
  49.             printf("\t%d\t",a[i][j]);
  50.         printf("\n");
  51.     }
  52.    
  53. }
  54. //Output
  55. //The matrix is:-
  56.  
  57. //  1       1       1       1       0  
  58. //  1       1       1       0       -1 
  59. //  1       1       0       -1      -1 
  60. //  1       0       -1      -1      -1 
  61. //  0       -1      -1      -1      -1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement