in ani?
HTML Code:
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<dos.h>
class student
{
private:
int id;
char name[50];
double tel;
public:
student ()
{
id=0;
strcpy(name,"");
tel=0;
}
void input()
{
cout<<" Enter The Name ";
gets(name);
cout<<endl;
cout<<" Enter The Telephone ";
cin>>tel;
}
void output()
{
gotoxy(6,2);
cout<<" The ID is " <<id<<endl;
cout<<endl;
cout<<" The Name is " <<name<<endl;
cout<<endl;
cout<<" The Telephone is "<<tel<<endl;
}
int getid()
{
return id;
}
void setid(int ide)
{
id=ide;
}
void setname(char naam[50])
{
strcpy(name,naam);
}
void student::view(int y)
{
gotoxy(6,2);
cout<<"----ID----";
gotoxy(35,2);
cout<<"----Name----";
gotoxy(63,2);
cout<<"----Telephone----";
gotoxy(10,y);
cout<<id;
gotoxy(39,y);
cout<<name;
gotoxy(69,y);
cout<<tel;
}
};student st[10];
void main()
{
clrscr();
int kamal=0;
int start;
int start2;
_setcursortype(_NOCURSOR);
start:
gotoxy(30,9);
cout<<" Add A Record ";
gotoxy(30,10);
cout<<" Search A Record ";
gotoxy(30,11);
cout<<" Delete A Record ";
gotoxy(30,12);
cout<<" Update A Record ";
gotoxy(30,13);
cout<<" View All Records ";
int y=9;
char key;
gotoxy(28,y);
cout<<"¯";
do
{
key =getch();
if(key==80 && y!=13)
{
gotoxy(28,y);
cout<<" ";
y++;
gotoxy(28,y);
cout<<"¯";
}
else if(key==72 && y!=9)
{
gotoxy(28,y);
cout<<" ";
y--;
gotoxy(28,y);
cout<<"¯";
}
else if(key==13 && y==9)
{
clrscr();
int id;
int x=0;
start2:
clrscr();
cout<<"Enter the id ";
cin>>id;
cout<<endl;
for(int c=0;c<10;c++)
{
if(st[c].getid()==id)
{
cout<<"This id already exists ";
x=1;
getch();
clrscr();
goto start2;
}
}
if (x==0)
{
st[kamal].setid(id);
st[kamal++].input();
}
getch();
clrscr();
goto start;
}
else if(key==13 && y==10)
{
clrscr();
int ID;
cout<<"Enter the ID ";
cin>>ID;
int x=0;
for(int j=0;j<=10;j++)
{
if(st[j].getid()!=0)
{
if(st[j].getid()==ID)
{
st[j].output();
x=1;
}
}
}
if(x==0)
{
cout<<"record not found ";
}
getch();
clrscr();
goto start;
}
else if (key==13 && y==11)
{
int ID;
int x=0;
clrscr();
cout<<"Enter the id ";
cin>>ID;
for(int i=0;i<10;i++)
{
if(st[i].getid()==ID)
{
st[i].setid(0);
x=1;
cout<<"Record has been deleted ";
}
}
if(x==0)
{
cout<<"yeah record to hay hi naheen tu nay apna sirr delete karna hay kiya ";
}
getch();
clrscr();
goto start;
}
else if(key==13 && y==12)
{
clrscr();
int ID;
cout<<"Enter the ID ";
cin>>ID;
int x=0;
for(int j=0;j<=10;j++)
{
if(st[j].getid()!=0)
{
if(st[j].getid()==ID)
{
st[j].output();
x=1;
char nname[50];
cout<<"Enter the new name ";
gets(nname);
st[j].setname(nname);
cout<<endl;
cout<<"record updated successfully ";
}
}
}
if(x==0)
{
cout<<"record not found ";
}
getch();
clrscr();
goto start;
}
else if(key==13 && y==13)
{
clrscr();
int y=3;
for(int i=0;i<kamal;i++)
{
if(st[i].getid()!=0)
{
st[i].view(y);
y++;
}
}
getch();
clrscr();
goto start;
}
else if(key==27)
{
exit(0);
}
}while(1);
}