All Programs are Written and Compiled in Dev C++. So, it may generate some error in case of other compilers and may need some modifications in program. Download Dev C++

Wednesday 26 February 2014

Deletion of A element from a tabular array

//Deletion of A element from a tabular array
#include<iostream.h>
#include<conio.h>
int main()
{
      int a[10];
      float b[10];
      char c[10][10];
      int m,i,loc;
      cout<<"Enter no of elements in array";
      cin>>m;
      cout<<"Enter Roll no, Marks & Name"<<endl;
      for(i=0;i<m;i++)
      {
     cin>>a[i]>>b[i];
     cin>>c[i];
      }
     
      cout<<"Enter the Place where to Delete";
      cin>>loc;
     
      for(i=loc;i<=m;i++)
      {
                        a[i-1]=a[i];
                        b[i-1]=b[i];
                        strcpy(c[i-1],c[i]);
                        }
      m=m-1;
//printing Table    
      cout<<"Roll No"<<"\t"<<"Marks"<<"\t"<<"Name"<<endl;
      for(i=0;i<m;i++)
      {
cout<<a[i]<<"\t"<<b[i]<<"\t";
cout<<c[i]<<endl;
      }
getch();
return 0;
}

No comments:

Post a Comment