EBOOK 4.4

1.) C++
#include <iostream>
#include <conio.h>
#include <stdio.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
int a[20], i, j, k ,n;
cout<<" enter aray size : ";
cin>>n;
cout<<" enter aray "<<n<<" elemen : \n";
for(i=0;i<n;i++){
    cin>>a[i];
    }
   
cout<<" new aray elemen are : ";
for(i=0;i<n;i++){
    for(j=i+1;j<n;){
        if(a[j]==a[i]){
            for(k=j;k<n;k++){
                a[k]=a[k+1];
            }
            n--;
        }
        else{
            j++;
        }
    }
}
for(i=0;i<n;i++){
    cout<<a[i]<<" ";
}
   
}

Share this

Related Posts

Previous
Next Post »