fork download
  1. #include<stdio.h>
  2.  
  3. int main () {
  4. float array[20];
  5. float max ,min,x;
  6. float rem;
  7. int i,j=0;
  8. char op;
  9. for (i=0; i<20; i++){
  10. printf("Enter the element inside array[%d]: ",i);
  11. if(scanf("%f",&x)==1){
  12. if(x<0.0)
  13. break;
  14. array[i]=x;
  15. }
  16. }
  17. printf("Enter ......: ");
  18. scanf(" %c", &op);
  19.  
  20. switch (op){
  21. case 'h':
  22. max = array[0];
  23. for (i= 0; array[i]; i++){
  24. if (max < array[i]){
  25. max = array[i];
  26. }
  27. }
  28. printf("The biggest number is: %f\n", max);
  29. break;
  30.  
  31. case 'l':
  32. min = array[0];
  33. for (i= 0; array[i]; i++){
  34. if (min > array[i]){
  35. min = array[i];
  36.  
  37. }
  38. }
  39. printf("The smallest number is: %f\n", min);
  40. break;
  41. }
  42. return 0;
  43. }
Success #stdin #stdout 0s 2160KB
stdin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
h
stdout
Enter the element inside array[0]: Enter the element inside array[1]: Enter the element inside array[2]: Enter the element inside array[3]: Enter the element inside array[4]: Enter the element inside array[5]: Enter the element inside array[6]: Enter the element inside array[7]: Enter the element inside array[8]: Enter the element inside array[9]: Enter the element inside array[10]: Enter the element inside array[11]: Enter the element inside array[12]: Enter the element inside array[13]: Enter the element inside array[14]: Enter the element inside array[15]: Enter the element inside array[16]: Enter the element inside array[17]: Enter the element inside array[18]: Enter the element inside array[19]: Enter ......: The biggest number is: 20.000000