Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

Program to delete values from the array in CPP (C plus plus)

Program to delete values from the array in CPP (C plus plus)

In this tutorial, we will learn about Program to delete values from the array in CPP (C plus plus) .

#include<iostream>
 
using namespace std;
 
int main()
{
    int array[50];
	int d;
	int no;
	int i;
	int j;
	int k[50];
	
    cout<<"Please enter the number of values of Array you want to create: ";
    cin>>no;
    
    cout<<endl<<"Please enter values in Array: "<<endl;
    
    for(i=0;i<no;++i)
        cin>>array[i];
        
    cout<<endl<<"Please enter the value you want to delete: ";
    cin>>d;
    
    for(i=0,j=0;i<no;++i)
    {
        if(array[i]!=d)
            k[j++]=array[i];
    }
 
    if(j==no)
    {
        cout<<endl<<"Sorry! Entered value not found in the Array";
        exit(0);
    }
    
    else
    {
        cout<<endl<<"Updated Array is ";
        for(i=0;i<j;i++)
            cout<<k[i]<<" ";
    }
 
    return 0;
}

Output:

Program to delete values from the array in CPP (C plus plus)

Program to delete values from the array in CPP (C plus plus)

Fazal Rehman Shamil Click Here to Know More
Instructor, Researcher, Blogger, SEO Expert, Poet and Publisher of International Journal Of Software, Technology & Science ISSN : 2616 - 5325
Dear Professors and Resarchers!You are welome to Cite these tutorials in your research or slides etc. Please don't forget to mention the reference of website. Copy Paste of text is strcitly forbidden. Images can be reuse because images are protected with watermark.

Leave a Reply

Your email address will not be published. Required fields are marked *