Program To Delete Duplicate Elements of An Array With 0 and Take All 0 To Right

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

62.

Program to delete duplicate elements of an array


with 0 and take all 0 to right.
#include<iostream.h>
void main()
{

int A[10];
cout<<"Enter array:";
for(int i=0; i<10; i++)
cin>>A[i];
for(i=0; A[i]!='\0'; i++)
{

for(int j=i+1; A[j]!='\0'; j++)


{

if(A[i]==A[j])
{

for(int k=j; A[k]!='\0'; k++)


A[k]=A[k+1];

}}
for(i=0; A[i]!='\0'; i++)
{

if(A[i]==0)
A[i]='\0';

cout<< \nNew array:;


for(i=0; i<10; i++)
cout<<A[i]<<" ";
}

You might also like