Mobile Phones
Software and Applications (non-game)
Computer Viruses
Email and IM
How To

How to attach a file or document to email in word 2007?

131415

Answer

User Avatar
Wiki User
09/08/2013

How to correct these errors

#include<iostream.h>

#include<conio.h>

#include<stdlib.h>

#include<stdio.h>

#include<ctype.h>

#define max 100

int stack[max];

int top;

void push(int stack[],int val,int &top);

int pop(int stack[],int top);

void showstack(int stack[],int &top);

void main()

{ clrscr();

int choice,val;

char opt='Y';

top =-1;

clrscr();

do

{ cout<<"\nMain Menu\n";

cout<<"\n 1. ADDITION OF STACK\n";

cout<<"\n 2. DELETION OF STACK\n";

cout<<"\n 3. TRAVERSAL OF STACK\n";

cout<<"\n 4.EXIT\n";

cin>>choice;

switch (choice)

{case 1:do

{cout<<"Enter the value to be ADDED"<<endl;

cin>>val;

void push(stack,val,top);/ error that /parameter is declared in body of the function

cout<<"DO YOU WANT to ADD MORE (Y/N):"; /error/ declaration missing;

cin>>opt;

}while(toupper(opt=='Y'));

break;

case 2:opt='Y';

do

{val=pop(stack,top);

if(val!=-1)

cout<<"VALUE DELETED FROM STACK :"<<endl;

cout<<val;

cout<<"DO YOU WANT TO CONTINUE:"<<endl;

cin>>opt;

}while(toupper(opt=='Y'));

break;

case 3:showstack(stack,top);

break;

case 4:exit(0);

break;

default:cout<<"YOu entered a wrong choice"<<endl;

}}while (choice!=4);

getch();

}

void push(int stack[],int val,int &top)

{if (top==max-1)

cout<<"STACK IS FULL"<<endl;

else

top=top+1;

stack[top]=val;

}

int pop(int stack[],int top)

{int value;

if(top<0)

{cout<<"STACK IS EMPTY"<<endl;

value=-1;

}

else

{value=stack[top];

top=top-1;

}

return(value);

}

void showstack(int stack[],int&top)

{int i;

if(top<0)

{cout<<"STACK IS EMPTY"<<endl;

}

i=top;

cout<<"THE VALUES ARE:"<<endl;

do

{cout<<stack[i]<<endl;

i=i-1;

}while(i>=0);

}