Computer Science, asked by karruu328, 1 year ago

Write a program stack to convert decimal ibteger into octal integer using stack

Answers

Answered by Avanish010
0

HI there,

Im Giving it in C language.

#include<stdio.h>

#define SIZE 10

int stack[SIZE];

int top=-1;

int empty();

int full();

void push(int x);

void pop();

void display();

int main(){

// code for conversion will come here

}

int empty(){

if(top==-1){

return 1;

}

else{

return 0;

}

}

int full(){

if(top==SIZE){

return 1;

}

else{

return 0;

}

}

void push(int x){

if(full()){

printf("Stack overflow!!\n");

}

else{

top++;

stack[top] = x;

}

}

void pop(){

if(empty()){

printf("Stack empty");

}

else{

top--;

}

}

void display(){

int i;

for(i=top;i>=0;i--){

printf("%d ",stack[i]);

}

}

Hope this will help you.

Similar questions