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

Enable shared folders in ubuntu in vmware?

 To enable Shared Folders in Ubuntu (VM) on VMware , follow these steps: Step 1: Enable Shared Folders in VMware Settings Power...