#include<stdio.h>
#include<conio.h>
#define MAX 10
int stack[MAX];
int top=-1;
void push(int);
void display();
void main()
{
int num;
printf{"enter a number"};
scanf("%d",&num);
push(num);
}
void push(int element)
{
if top==max-1
{
printf("state overflow\n");
return;
}
else
{
top=top+1;
stack[top]=element;
}
}
#include<conio.h>
#define MAX 10
int stack[MAX];
int top=-1;
void push(int);
void display();
void main()
{
int num;
printf{"enter a number"};
scanf("%d",&num);
push(num);
}
void push(int element)
{
if top==max-1
{
printf("state overflow\n");
return;
}
else
{
top=top+1;
stack[top]=element;
}
}
i try to debug it like
ReplyDelete#include
#include
#define MAX 10
int stack[MAX];
int top=-1;
void push(int);
void display();
main()
{
int num;
printf("enter a number");
scanf("%d",&num);
push(num);
}
void push(int element)
{
if (top == MAX-1)
{
printf("state overflow\n");
return;
}
else
{
top=top+1;
stack[top]=element;
}
}
Give a heading about which the program is, so that users can debug it and increase its readability.
ReplyDeletesorry for that and this programme is about push function in stack using array
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteIts a C programming,
ReplyDelete1. header file is missing,
2. void datatype is not valid is C, its supporting as the compiler is supporting C and C++ both.
3. display() function is not defined, its only declared,
4. If we run the program, after entering any number, its terminated.
Try to debug it properly again.