C Program For Selection Sort of different Numbers using array. Without using any string functions
#include<stdio.h>#include<conio.h>void main(){int k;do{int a[100],n,temp,i,j,s,num,l,u,m,o,flag=0;clrscr();printf(" Enter No Of Elements : ");scanf("%d",&n);for(i=0;i<n;i++){printf("\n Enter The %d Element : ",(i+1));scanf("%d",&a[i]);}printf("\n The Entered Array Is \n");for(i=0;i<n;i++)printf("%d , ",a[i]);for(i=0;i<n;i++){for(j=i+1;j<n;j++){if(a[i]>a[j]){temp=a[i];a[i]=a[j];a[j]=temp;}}}printf("\n Enter the element to be searched : ");scanf("%d",&num);l=0;o=n;while(l<=n){m=(l+o);if(a[m]==num){printf(" The Number is found at the Position %d ",m+1);flag=1;break;}else if(num<a[m])o=m-1;elsel=m+1;}if(flag==0)printf("\n The Number is Absent in the entered Array");getch();printf("\n\n\t*** Do U Want To Continue Press 1 ***");printf("\n\t Enter YOur Choice, For exit Simply click Any Other Key ");scanf("%d",&k);}while(k==1);}
|
Loading...
|
Comments :
Post a Comment
Enter any comments