Write an algorithm/program to push an element in array implemented stack.
#include <stdio.h>
int stack[1024];
int top = -1;
int push(int data) {
if (top < 1023) {
top = top + 1;
stack[top] = data;
return 1;
} else {
return 0;
}
}
int main() {
push(2);
push(3);
return 0;
}
Comments
Leave a comment