1. Write a program that asks the user to type 10 integers of an array and an integer value V. The program must search if the value V exists in the array and must remove the first occurrence of V, shifting each following element left and adding a zero at the end of the array. The program must then write the final array.
#include<iostream>
usingnamespace std;
int main()
{
int array[10];
int input, ctr=0, move;
for (int x=0; x<10; x++)
{
cout<<"Enter a number on index ["<<x<<"]: "; cin>>array[x];
}
int v;
cout<<"Enter the value of 'v': "; cin>>v;
for (int y=0; y<10; y++)
{
if (array[y]==v)
{
if (ctr==0)
{
ctr=y;
}
}
}
if (ctr==0)
{
cout<<endl<<"***Cannot find Value of v is not in the array***"<<endl;
}
elseif (ctr!=0)
{
move=array[ctr];
for (longint z=ctr; z<10; z++)
{
array[z]=array[move];
move++;
}
array[9]=0;
for (int d=0; d<10; d++)
{
cout<<array[d]<<", ";
}
}
return 0;
}
the last time i check,
theres bug when i use 2 digits
any suggestions how to fix this will be much appreciated :)