Advertisement
Nahid8195

Matrix

Sep 14th, 2022
789
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int Id(int num)
  4. {
  5.     int row, col;
  6.  
  7.     for (row = 0; row < num; row++)
  8.     {
  9.         for (col = 0; col < num; col++)
  10.         {
  11.             if (row == col)
  12.                 printf("%d ", 1);
  13.             else
  14.                 printf("%d ", 0);
  15.         }
  16.         printf("\n");
  17.     }
  18.     return 0;
  19. }
  20.  
  21. int main()
  22. {
  23.     int size;
  24.     printf("Enter the size: ");
  25.     scanf("%d",&size);
  26.     Id(size);
  27.     return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement