Saturday, August 18, 2018

ARRAY: PROGRAM TO DELETE THE SPECIFIED INTEGER FROM AN ARRAY

#include<stdio.h>
void main()
{
int arr[5],i,j,x,f=0,k=0;
printf("Enter the element of an array:");
for(i=0;i<5;i++)
{
scanf("%d",&arr[i]);
}
printf("Enter the element you want to delete:");
scanf("%d",&x);
for(i=0;i<5;i++)
{
if(arr[i]==x)
{
f=1;
for(j=i;j<4;j++)
{
arr[j]=arr[j+1];
}
k++;
}
}
if(f==0)
{
printf("No such element present in an array");
}
else
{
printf("Elements after deleting the element:");
for(i=0;i<5-k;i++)
        {
        printf("%d,",arr[i]);
}
}

}
OUTPUT:

No comments:

Post a Comment

Static Member Function

CODE : #include<iostream> using namespace std; class test  {     int code;       static int count;               //static...