Saturday, May 21, 2011

Program C Menghapus Data

//Program menghapus data//
#include <stdio.h>
#include <conio.h>

int main ()
{
      int A [5] = {20,9,1986,200,13}, n, hapus;
      printf("Program untuk menghapus data\n\n");
      printf("Data yang lama\n");
      for(n=0; n<5; n++)
      {
               printf("%d ", A[n]);
      }
      printf("\nPosisi data yang ingin dihapus:");
      scanf("%d", &hapus);
      printf("Data yang baru\n");
      for( n=hapus-1; n<5-1; n++)
      {
           A[n] = A[n+1];
      }
      for(n=0; n<4; n++)
      {
               printf("%i ", A[n]);
      }
      printf("\n\n====================================================\n");
      printf("\t\tVera Suryaningsih\n\tCopyright spirit221.blogspot.com\n");
      printf("\n====================================================\n");
      getch ();
      return 0;
}

Output

0 comments:

Post a Comment