• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
projectsgeek

ProjectsGeek

Download Mini projects with Source Code, Java projects with Source Codes

  • Home
  • Java Projects
  • C++ Projects
  • VB Projects
  • PHP projects
  • .Net Projects
  • NodeJs Projects
  • Android Projects
    • Project Ideas
      • Final Year Project Ideas
      • JSP Projects
  • Assignment Codes
    • Fundamentals of Programming Language
    • Software Design Laboratory
    • Data Structure and Files Lab
    • Computer Graphics Lab
    • Object Oriented Programming Lab
    • Assembly Codes
  • School Projects
  • Forum

Database Operations without pointers source code

June 26, 2011 by ProjectsGeek Leave a Comment

Database Operations without pointers

Objective

Program for Operations on a database without using pointers. This program in c/c++ will simulate database operations such as create record, insert, delete, search, print, sort and modify records using simple menu interface which is provided to interact with the program.
Program developed using c/c++ starts with menu options where user can provide data such as employee details. User needs to provide number of employees we want to insert into the database. After entering number of employees we want to insert user can provide data inform of employee name, employee id, salary for particular employee. As soon as entered is pressed record will be inserted into database.
For more c programs check here.
Database Operations without pointers
 #include  
 #include  
 #include  
 typedef struct employee  
 { int code;  
 char name[20];  
 int salary;  
 }employee;  
 void insert(employee st[],int position,int n);  
 void Delete(employee st[],int position,int n);  
 int search(employee st[],int code,int n);  
 void print(employee st[],int n);  
 void read(employee st[],int n);  
 void sort(employee st[],int n);  
 void modify(employee st[],int n);  
 void main()  
 { employee st[30];  
 int n,i,op,position,code;  
 clrscr();  
 do{  
 flushall();  
 printf("\n1)create\n2)insert\n3)delete\n4)search\n5)print\n6)Sort\n7)Modify");  
 printf("\n8)Quit");  
 printf("\nEnter Your Choice:");  
 scanf("%d",&op);  
 switch(op)  
 { case 1: printf("\nEnter No. of employees:");  
 scanf("%d",&n);  
 read(st,n);  
 break;  
 case 2: printf("\n enter the position(no of records=%d):",n);  
 scanf("%d",&position);  
 if(position<=n+1)  
 {  
 insert(st,position,n);  
 n++;  
 print(st,n);  
 }  
 else  
 printf("\n can not insert");  
 break;  
 case 3:printf("\n enter the code : ");  
 scanf("%d",&code);  
 position=search(st,code,n);  
 if(position != -1 )  
 {  
 Delete(st,position,n);  
 n--;  
 print(st,n);  
 }  
 else  
 printf("\n can not delete ");  
 break;  
 case 4: printf("\nenter code:");  
 scanf("%d",&code);  
 position=search(st,code,n);  
 if(position==-1)  
 printf("\nnot found");  
 else  
 { printf("\n found at location=%d",position+1);  
 printf("\n %s\t%d\t%d",st[position].name,st[position].code,st[position].salary);  
 }  
 break;  
 case 5: print(st,n);  
 break;  
 case 6: sort(st,n);print(st,n);break;  
 case 7: modify(st,n);print(st,n);break;  
 }  
 }while(op!=8);  
 }  
 void insert( employee st[],int position,int n)  
 { int i;  
 printf("\n enter data(name code salary): ");  
 for(i=n-1;i>=position-1;i--) /*index is 1 less than position*/  
 st[i+1]=st[i];  
 scanf("%s%d%d",st[position-1].name,&st[position-1].code,&st[position-1].salary);  
 }  
 void Delete(employee st[],int position,int n)  
 { int i;  
 for(i=position+1;i st[j+1].code)  
 {  
 temp=st[j];  
 st[j]=st[j+1];  
 st[j+1]=temp;  
 }  
 }  

Output

1)create
2)insert
3)delete
4)search
5)print
6)Sort
7)Modify
8)Quit
Enter Your Choice:1

Enter No. of employees:2

enter data(name code salary): John 1 2000
Jenny 2 3000

1)create
2)insert
3)delete
4)search
5)print
6)Sort
7)Modify
8)Quit
Enter Your Choice:2

enter the position(no of records=2):3

enter data(name code salary): Merry 3 5000

John 1 2000
Jenny 2 3000
Merry 3 5000
1)create
2)insert
3)delete
4)search
5)print
6)Sort
7)Modify
8)Quit
Enter Your Choice:3

enter the code : 2

John 1 2000
Merry 3 5000
1)create
2)insert
3)delete
4)search
5)print
6)Sort
7)Modify
8)Quit
Enter Your Choice:4

enter code:3

found at location=2
Merry 3 5000
1)create
2)insert
3)delete
4)search
5)print
6)Sort
7)Modify
8)Quit
Enter Your Choice:5

John 1 2000
Merry 3 5000
1)create
2)insert
3)delete
4)search
5)print
6)Sort
7)Modify
8)Quit
Enter Your Choice:6

John 1 2000
Merry 3 5000
1)create
2)insert
3)delete
4)search
5)print
6)Sort
7)Modify
8)Quit
Enter Your Choice:7

Enter the code : 3

enter data(name code salary): Diya 5 4000

John 1 2000
Diya 5 4000
1)create
2)insert
3)delete
4)search
5)print
6)Sort
7)Modify
8)Quit
Enter the code : 8

 

 

 

Other Projects to Try:

  1. Mobile User Information Project
  2. Hash table code in C Language
  3. String Operations with Pointers
  4. Matrix Operations with Pointers
  5. Sparse Matrix Operations Code using C Langauge

Filed Under: Fundamentals of Datastructure Tagged With: Datastructure Assignments

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Tags

.Net Projects Download Android Project Ideas Android Projects Angular 2 Assembly Codes C # Projects C & C++ Projects C++ Projects Class Diagrams Computer Graphics Database Project Data Mining Projects DataScience Projects Datastructure Assignments Download Visual Basic Projects Electronics project Hadoop Projects Installation Guides Internet of Things Project IOS Projects Java Java Interview Questions Java Projects JavaScript JavaScript Projects java tutorial JSON JSP Projects Mechanical Projects Mongodb Networking Projects Node JS Projects OS Problems php Projects Placement Papers Project Ideas Python Projects seminar and presentation Struts

Search this Website


Footer

Download Java Project
Download Visual Basic Projects
Download .Net Projects
Download VB Projects
Download C++ Projects
Download NodeJs Projects
Download School Projects
Download School Projects
Ask Questions - Forum
Latest Projects Ideas
Assembly Codes
Datastructure Assignments
Computer Graphics Lab
Operating system Lab
australia-and-India-flag
  • Home
  • About me
  • Contact Form
  • Submit Your Work
  • Site Map
  • Privacy Policy