Advertisement
Guest User

jomernoo

a guest
Dec 8th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3.  
  4. void main(){
  5. int numbers, num[10], count, i, j, temp, locate, mid;
  6.  
  7. printf("Enter how many numbers to be inputted: ");
  8. scanf("%d",&count);
  9.  
  10. for(i=0;i<=count-1;i++){
  11. printf("Enter a number: ");
  12. scanf("%d",&num[i]);
  13. }
  14.  
  15. for(i=0;i<=count-1;i++){
  16. for(j=0;j<=count-1;j++){
  17. if(num[j]>num[j+1]){
  18. temp=num[j];
  19. num[j]=num[j+1];
  20. num[j+1]=temp;
  21. }
  22. }
  23. }
  24.  
  25. mid = count/2
  26.  
  27. printf("Number to locate: ");
  28. scanf("%d",&locate);
  29.  
  30. if(locate==num[mid]){
  31. printf("The number has been found");
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement