Answer to Question #256117 in C for Garima

Question #256117

Write an algorithm/program to push an element in array implemented stack.


1
Expert's answer
2021-10-27T00:26:14-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS