Write a program to convert decimal ibteger into binary integer using stack
Answers
Answered by
0
Hi there,
Here's the program 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 it will help you
Similar questions
English,
7 months ago
Social Sciences,
7 months ago
Chemistry,
7 months ago
Science,
1 year ago
Chemistry,
1 year ago