Code In Tech - The Ultimate World of Computer Technology

Sunday, 22 April 2012

C program for 2d array replace by zero

SOURCE CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
 int i,j,a[3][3];
 clrscr();
 for(i=0;i<3;i++)
 {
  for(j=0;j<3;j++)
  {

   printf("a[%d][%d]=",i,j);
   scanf("%d",&a[i][j]);
   if(a[i][j]<0)
   {
    a[i][j]=0;
   }
  }
 }
 printf("this is your matrix\n");
 for(i=0;i<3;i++)
 {
  for(j=0;j<3;j++)
  {
   printf("%d\t",a[i][j]);
  }
  printf("\n");
 }
 getch();
}

No comments :

Post a Comment