Wednesday, February 23, 2011

Initialize diagonal element with zero in a 2d array

 


#include <stdio.h>
#include <conio.h>
#include <string.h>
static int count=0;
static int pathsize;

void main()
{
int array[5][5];
int i=0,j=0;
for(i=0;i<5;i++)
array[i][i]=0;
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
printf(" [%d] ",array[i][j]);
}
printf("\n");
}
getch();
}

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

#Linux Commands Unveiled: #date, #uname, #hostname, #hostid, #arch, #nproc

 #Linux Commands Unveiled: #date, #uname, #hostname, #hostid, #arch, #nproc Linux is an open-source operating system that is loved by millio...