Write a program to set all the diagonal elements of a two dimensional array to 1 and others to 0

#include<stdio.h>
#include<conio.h>
main()
{


     int a[10][10],i,j;       //...{a,i,j,n,i,o, gnimit si sgniht yreve}
     for(i=0;i<=8;i++)
       {
    for(j=0;j<=8;j++)
      {
       if(i==j || i+j==8)
         printf("1  ");
       else
         printf("0  ");
      }
    printf("\n\n");
       }

    getch();
}
Next Post Previous Post
No Comment
Add Comment
comment url