#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int c;
int array[10]={22,11,33,44,55,66,77,32,13,54};
for(c=0;c<10;c++)
printf("%d\n",array[c]);
printf("Every Third Element will be deleted automatically\n\n");
int position=0;
while(position%2==0&position<10)
{
array[c]=array[c+1];
printf("%d\n",array[c]);
position++;
}
return 0;
}
A few things which could go wrong there. At line 15 the & operator should be &&.
The expression position%2 could be helpful in dealing with every second element. I think you should be using something involving %3 instead.
At line 17, what is the value of c? It will start out at whatever its value was after the end of the loop at line 8. That is, it starts out as c=10, and array[10] is outside the array.
That aside, the algorithm you are trying to use doesn't look right to me. It needs a bit of a re-think. It can be useful to use pen and paper to sketch out how you want the algorithm to work, using diagrams showing the contents of the array at each stage, and the corresponding values of the subscripts.
Break the problem into two parts.
1) Create a loop that identifies every third element in the array.
2) Create a separate function to delete an arbitrary element from the array.
Keep in mind that if you work from the front of the array to the end, when you delete an element of the array, the relative position of subsequent elements changes. You might consider working from the end of the array to the front, that way the relative position of elements yet to check remains unchanged.