Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
turboc++
#include<iostream.h>
#include<conio.h>
int a = 2, b = 3, c = 4, i = 0;
//Define class
class lib {
int n;
public:
void issue();
void show();
void ret();
};
void lib::issue() {
cout << "enter code:";
cin >> n;
switch (n) {
case 101:
if (a != i) {
a--;
cout << "NCERT mano is issued\nno. of books=" << a << "\n\n";
}
break;
case 102:
if (b != i) {
b--;
cout << "peter syckes is issued\n no. of book=" << b << "\n\n";
}
break;
case 103:
if (c != i) {
c--;
cout << "ncert maths is issued\n no. of book=" << c << "\n\n";
}
break;
}
}
void lib::ret() {
cout << "enter code to return the book:";
cin >> n;
switch (n) {
case 101:
if (a != 2) {
a++;
cout << "NCERT mano is returned\nno. of books=" << a;
}
break;
case 102:
if (b != 3) {
b++;
cout << "peter syckes is returned\n no. of book=" << b;
}
break;
case 103:
if (c != 4) {
c++;
cout << "NCERT maths is returned\n no. of book=" << c;
}
break;
}
}
void lib::show() {
cout << "book code:101\n";
cout << "name: NCERT mano\n";
cout << "availability:" << a << "\n\n";
cout << "book code:102\n";
cout << "name: peter sykes\n";
cout << "availability:" << b << "\n\n";
cout << "book code:103\n";
cout << "name: NCERT maths\n";
cout << "availability:" << c << "\n\n";
}
void main() {
class lib lb;
int k, m;
clrscr();
x:
cout << "enter 1 to see the list of books\n";
cout << "enter 2 to issue the book\n";
cout << "enter 3 to return the book\n";
cout << "number:";
cin >> k;
switch (k) {
case 1:
lb.show();
cout << "\nenter 0 to go to previous:";
cin >> m;
if (m == 0)
goto x;
else
break;
case 2:
lb.issue();
cout << "\nenter 0 to go to previous:";
cin >> m;
if (m == 0)
goto x;
else
break;
case 3:
lb.ret();
cout << "\nenter 0 to go to previous:";
cin >> m;
if (m == 0)
goto x;
else
break;
}
getch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.