Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include<iostream>
  2. #include<conio.h>
  3.  
  4. using namespace std;
  5.  
  6. void main() {
  7. int count;
  8. int greatest = 0;
  9. int arr[100];
  10. cout << "enter the number of input you want to execute" << endl;
  11. cin >> count;
  12.  
  13. for (int i = 0; i < count; i++) {
  14.  
  15. cout << "enter a number: ";
  16. cin>>arr[i];
  17. }
  18. for (int i = 0; i < count; i++) {
  19.  
  20. if (arr[i] > greatest) {
  21. greatest=arr[i];
  22. }
  23.  
  24. }
  25.  
  26. int smallest = arr[0];
  27.  
  28. for (int i = 0; i < count; i++) {
  29.  
  30. if (arr[i]<smallest){
  31. smallest = arr[i];
  32. }
  33.  
  34. }
  35. system("cls");
  36. cout << "\n\n\n\n";
  37. cout << "the greatest number is: " << greatest << endl;
  38. cout << "the smallest number is: " << smallest <<"\n\n\n";
  39.  
  40. _getch();
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement