• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
 
#include<stdio.h>#include<conio.h>#include<stdlib.h>int arr[10];void main(){int a, b,c;clrscr(); printf("Enter the number of elements of array(less than 10): ");scanf("%d", &a); printf("\n\nEnter array: \n");for(b=0; b<a; b++){scanf("%d", &arr[b]);} printf("\n\nYour entered array is: \n");for(b=0; b<a;b++){ printf("%d ", arr[b]);} printf("\n\nChoose your option for further operation on array\n"); printf("\n1. Sort"); printf("\n2. Search"); printf("\n3. Insert"); printf("\n4. Delete\n\n");scanf("%d",&c);switch(c){case 1:sort_array(a); break;case 2:search_array(a); break;case 3:insert_element(a); break;case 4:delete_element(a); break;default: printf("Thank You for using this");}getch();}
 
sort_array(int u){int i,r=0;int temp;for(i=0; i<u; i++){for(r=i+1; r<u; r++){if(arr[i]>arr[r]){temp=arr[i];arr[i]=arr[r];arr[r]=temp;}}} printf("\n\nYour sorted array is: ");for(i=0; i<u; i++){ printf("%d ", arr[i]);}return(0);}search_array(int u){int x,i; printf("\nEnter the element you want to search: ");scanf("%d", &x);for(i=0; i<u; i++){if(arr[i]==x){ printf("Your element is present at location number %d", i+1); break;}}return(0);}insert_element(int u){int a,z,i,x; printf("\nEnter a number to include in array: ");scanf("%d", &a); printf("\nEnter the position where u want to place it in array: ");scanf("%d", &z);x=u;if(z<=u||z>0)
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...