fork download
  1. // Online C compiler to run C program online
  2. #include <stdio.h>
  3. #include<stdlib.h>
  4. struct stack{
  5. int size;
  6. int top;
  7. int *ptr;
  8. };
  9. int isempty(struct stack *arr)
  10. {
  11. if(arr->top==-1){
  12. return 1;
  13. }
  14. else{
  15. return 0;
  16. }
  17. };
  18. int isfull(struct stack *arr)
  19. {
  20.  
  21. if(arr->top==arr->size-1){
  22. return 1;
  23. }
  24. else{
  25. return 0;
  26. }
  27. };
  28.  
  29. int main() {
  30. // Write C code here
  31. struct stack*s;
  32. s->size=8;
  33. s->top=-1;
  34. s->ptr=(int*)malloc(s->size*sizeof(struct stack));
  35. s->ptr[0]=9;
  36. s->top++;
  37.  
  38. if(isempty(s)){
  39. printf("the stack is empty");
  40.  
  41. }
  42. else{
  43. printf("the stack is not emtpy");
  44. }
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
the stack is not emtpy