#include <stdio.h>
int stack[100];
int top = -1;
void push(int x){
stack[++top] = x;
}
void pop(){
top = -1;
}
int main(){
int arr[] = {2,4,7,6,8};
for (int i = 0;i < 5;i++) {
if (arr[i] % 2 == 1) {
pop();
}else{
push(arr[i]);
}
}
for (int i = 0; i <= top; i++) {
printf("%d ", stack[i]);
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: