online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include<iostream> #include<string.h> #include<conio.h> #include<stdlib.h> using namespace std; int main(); void show(int search_key); void get(int i); void searchdata(int search_key); void add_name(); void update(int id_number); // void delete_data(int id_number); int ts; struct student { int rollno; string name; string fname; string phoneno; string dob; string address; }; student s[60]; int main() { system("cls"); int choice; int id_number; int search_key; cout<<"enter total students:"<<endl; cin>>ts; while(ts--) { cout<<"\nwhat operation to do"<<endl; cout<<"\nadd student"<<endl; cout<<"\nupdate record"<<endl; cout<<"\nsearch record"<<endl; //cout<<"\ndelete record"<<endl; cout<<"\nquit the database"<<endl; cout<<"enter the choice"<<endl; cin>>choice; switch(choice) { case 1: add_name(); break; case 2: if(s[0].rollno == 0) { cout<<"enter record first"<<endl; system("pause"); main(); } else { cout<<endl; cout<<"Student record table"<<endl; cout<<"ID "<<"ROLLNO "<<"NAME "<<"PHONE "<<"DOB "<<"ADDRESS "<<endl<<endl; for(int i=0;i<ts;i++) { show(i); } cout<<"enter the id number to be edited"<<endl; cin>>id_number; if(id_number>ts||id_number<0) { cout<<"invalid id number passed"<<endl; } else{ update(id_number); } break; } case 3: if(s[0].rollno == 0) { cout<<"enter student record first"<<endl; } else { cout<<"enter id for search"<<endl; cin>>search_key; searchdata(search_key); } break; /*case 4: if(s[0].rollno == 0) { cout<<"enter student record first"<<endl; } else { cout<<"enter id to be deleted"<<endl; cin>>id_number; delete_data(id_number); } break;*/ case 5: return 0; break; default: cout<<"invalid choice"<<endl; system("pause"); main(); } } return 0; } void get(int i) { cout<<"enter student rollno"<<endl; cin>>s[i].rollno; cout<<"enter student name"<<endl; cin>>s[i].name; cout<<"enter student fname"<<endl; cin>>s[i].fname; cout<<"enter student phoneno"<<endl; cin>>s[i].phoneno; cout<<"enter student dob"<<endl; cin>>s[i].dob; cout<<"enter student address"<<endl; cin>>s[i].address; } void show(int search_key) { int i = search_key; cout<<i<<" "; cout<<s[i].rollno<<" "; cout<<s[i].name<<" "; cout<<s[i].fname<<" "; cout<<s[i].phoneno<<" "; cout<<s[i].dob<<" "; cout<<s[i].address<<" "; } void searchdata(int search_key) { for(int i=0;i<ts;i++) { if(s[i].rollno == search_key) { cout<<"ID "<<"ROLLNO "<<"NAME "<<"PHONE "<<"DOB "<<"ADDRESS "<<endl<<endl; show(i); } } } void add_name() { for(int i=0;i<ts;i++) { get(i); } system("cls"); cout<<endl; cout<<"student record table"<<endl; cout<<"ID "<<"ROLLNO "<<"NAME "<<"PHONE "<<"ADDRESS "<<endl<<endl; for(int i=0;i<ts;i++) { show(i); } system("pause"); cout<<"student record added"<<endl; main(); } void update(int id_number) { for(int i=0;i<ts;i++) { if(id_number == i) { cout<<"existed record"<<endl; cout<<"ID "<<"ROLLNO "<<"NAME "<<"PHONE "<<"ADDRESS "<<endl<<endl; show(i); cout<<"taking new record for same id"<<endl; get(i); cout<<"record updated"<<endl; system("pause"); main(); } } }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue