Please help me build a C program where it implements a stack
Please help me build a C# program where it implements a stack of characters using a linked list as its underlying physical data structure. The program must check empty stack when it pops. the Main method should test the stack. In particular, the stack is to be utilized to check if a string of user input is a Palindrome or not! Computer Science
Solution
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class stock
{
char author[50];
char title[50];
char pub[50];
double price;
int numcopies;
public:
stock();
int access_title(char a[]);
void input();
void getdata(int);
};
stock::stock()
{
char author[50]={\"abc\"};
char title[50]={\"efg\"};
char pub[50]={\"hij\"};
price=500;
numcopies=50;
}
int stock::access_title(char a[])
{
if(strcmp(title,a))
return 0;
else return 1;
}
void stock::getdata(int num)
{
if(numcopies>=num)
cout<<\"\ Cost of \"<<num<<\" books is Rs. \"<<(price*num);
else
cout<<\"\ Sorry! These many copies are unavailable!\";
}
void stock::input()
{
cout<<\"\ Title: \";
gets(title);
cout<<\"\ Author:\";
gets(author);
cout<<\"\ Publisher:\";
gets(pub);
cout<<\"\ Prices:\";
cin>>price;
cout<<\"\ copies available:\";
cin>>numcopies;
}
void main()
{
clrscr();
stock obj[2];
int n;
char ttle[50];
cout<<\"Enter details of 3 books\";
for(int i=0;i<2;++i)
obj[i].input();
cout<<endl;
cout<<\"\ Enter title of required book\ \";
gets(ttle);
for(i=0;i<2;i++)
{
if(obj[i].access_title(ttle))
{
cout<<\"\ How many copies? \";
cin>>n;
obj[i].getdata(n);
}
else
cout<<\"\ Book unavailable\";
}
getch();
}


