• 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

Mobile User Information Project

June 26, 2011 by ProjectsGeek Leave a Comment

Program for Mobile user information

Program details:

1. Display the data in descending order of Mobile No.(insertion sort).
2. Display data in ascending order of name (selection sort).
3. Display details of Mobileno specified by user (Binary search).
4. Display the number of passes and comparisons for different test cases(
(Worst, Average,Best case).

 

;i++)>;i++)>

 #include  
 #include  
 #include  
 #include  
 typedef struct mobile  
 { long mobileno;  
 char name[20];  
 float billamt;  
 }mobile;  
 int binsearch(mobile st[],long mobileno,int n);  
 /* Different cases for searching :  
 Best case - Data being searched is exactly at the centre  
 worst Case - Data being searched is not there.  
 Average Case - Data being searched is at a random place .  
 */  
 void print(mobile st[],int n);  
 void read(mobile st[],int n);  
 void insertionsort(mobile a[],int n); //sort in descending order on MobileNo  
 /* Different cases for insertin sort  
 Best case : when the data is already sorted in descending order on mobileno  
 worst case: when the data is already sorted in ascending order on mobileno.  
 Average case : when the data is in a random sequence  
 */  
 void selectionsort(mobile a[],int n);  
 /*Different cases for selection sort :  
 Only one case :  
 No. of passes = n-1  
 no. of comparisons= n(n-1)/2  
 */  
 void main()  
 { mobile st[30];  
 int n,i,op,position;  
 long mobileno;  
 clrscr();  
 do{  
 flushall();  
 printf("\n1)create\n2)print");  
 printf("\n3)Display the data in descending order of mobileno(insertion sort)");  
 printf("\n4)Display the data in ascending order of name(selection sort)");  
 printf("\n5)Display details for mobileno specified by user(binary search)");  
 printf("\n6)Quit");  
 printf("\nEnter Your Choice:");  
 scanf("%d",&op);  
 switch(op)  
 { case 1: printf("\nEnter No. of Users :");  
 scanf("%d",&n);  
 read(st,n);  
 break;  
 case 2: print(st,n);break;  
 case 3: insertionsort(st,n); print(st,n); break;  
 case 4: selectionsort(st,n); print(st,n); break;  
 case 5: printf("\nPlease ensure that data is sorted using option no.3");  
 printf("\nenter Mobile number : ");  
 scanf("%ld",&mobileno);  
 position=binsearch(st,mobileno,n);  
 if(position==-1)  
 printf("\nnot found");  
 else  
 { printf("\n found at location=%d",position+1);  
 printf("\n %s\t%ld\t%6.2f",st[position].name,st[position].mobileno,st[position].billamt);  
 }  
 break;  
 }  
 }while(op!=6);  
 }  
 int binsearch(mobile st[],long mobileno,int n)  
 { int i,j,k,comp=0;  
 i=0;  
 j=n-1;  
 while(i<=j)  
 {  
 k=(i+j)/2;  
 comp++;  
 if(mobileno==st[k].mobileno)  
 {  
 printf("\nNo. of comparisons = %d ",comp);  
 return(k);  
 }  
 else  
 if(mobileno > st[k].mobileno)  
 j=k-1;  
 else  
 i=k+1;  
 }  
 printf("\nNo. of comparisons = %d ",comp);  
 return(-1);  
 }  
 void print(mobile st[],int n)  
 { int i;  
 for(i=0;i=0 && a[j].mobileno < temp.mobileno;j--)  
 {  
 comp++;  
 a[j+1]=a[j];  
 }  
 a[j+1]=temp;  
 }  
 printf("\nPasses = %d\t Comparisons = %d",passes,comp);  
 }  
 void selectionsort(mobile a[],int n)  
 {  
 int i,j,k,passes=0,comp=0;  
 mobile temp;  
 for(i=0;i< 0 )  
 k=j;  
 }  
 temp=a[i];  
 a[i]=a[k];  
 a[k]=temp;  
 }  
 printf("\nPasses = %d\t Comparisons = %d",passes,comp);  
 }  

Output

1)create
2)print
3)Display the data in descending order of mobileno(insertion sort)
4)Display the data in ascending order of name(selection sort)
5)Display details for mobileno specified by user(binary search)
6)Quit
Enter Your Choice:1

Enter No. of Users :3

enter data(name mobile No.(9 disgits max) Bill Amount ):
Shreya 989087256 2289
Shruti 976015736 1345
Shina 989076543 1100

1)create
2)print
3)Display the data in descending order of mobileno(insertion sort)
4)Display the data in ascending order of name(selection sort)
5)Display details for mobileno specified by user(binary search)
6)Quit
Enter Your Choice:2

Shreya 989087256 2289.00
Shruti 976015736 1345.00
Shina 989076543 1100.00
1)create
2)print
3)Display the data in descending order of mobileno(insertion sort)
4)Display the data in ascending order of name(selection sort)
5)Display details for mobileno specified by user(binary search)
6)Quit
Enter Your Choice:3

Passes = 2 Comparisons = 1
Shreya 989087256 2289.00
Shina 989076543 1100.00
Shruti 976015736 1345.00
1)create
2)print
3)Display the data in descending order of mobileno(insertion sort)
4)Display the data in ascending order of name(selection sort)
5)Display details for mobileno specified by user(binary search)
6)Quit
Enter Your Choice:4

Passes = 2 Comparisons = 3
Shina 989076543 1100.00
Shreya 989087256 2289.00
Shruti 976015736 1345.00
1)create
2)print
3)Display the data in descending order of mobileno(insertion sort)
4)Display the data in ascending order of name(selection sort)
5)Display details for mobileno specified by user(binary search)
6)Quit

Enter Your Choice:5

Please ensure that data is sorted using option no.3
enter Mobile number : 976015736

No. of comparisons = 2
found at location=3
Shruti 976015736 1345.00
1)create
2)print
3)Display the data in descending order of mobileno(insertion sort)
4)Display the data in ascending order of name(selection sort)
5)Display details for mobileno specified by user(binary search)
6)Quit
Enter Your Choice:6

Other Projects to Try:

  1. Bubble Sort Code in C Language
  2. Database Operations without pointers source code
  3. Quick sort using recursion
  4. Matrix Operations with Pointers
  5. Operations on matrices like addition, multiplication, saddle point, magic square ,inverse & transpose

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