Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. //Alano, Raphael D.
- 2. //IT-01
- 3.
- 4. #include<iostream>
- 5. using namespace std;
- 6. int main()
- 7. {
- 8. int num[5];
- 9. int total;
- 10. int x;
- 11. int temp;
- 12. float average;
- 13.
- 14. cout << "Input 5 random numbers."<<endl;
- 15. for(x=0;x<=4;x++)
- 16. {
- 17. cout << "No. [" << x+1 << "]"<<endl;
- 18. cin >> num[x];
- 19. total= total+num[x];
- 20. }
- 21. average=total/x;
- 22.
- 23. cout<<"The total is: " <<total<<endl;
- 24. cout<<"The average is: " <<average<<endl;
- 25.
- 26. for (x = 0; x <= 4; x++)
- 27. {
- 28. for (int i = x + 1; i <= 4; i++)
- 29. {
- 30. if (num[x] > num[i])
- 31. {
- 32. temp = num[x];
- 33. num[x] = num[i];
- 34. num[i] = temp;
- 35. }
- 36. }
- 37. }
- 38. cout<<"The minimum is: "<<num[0];
- 39. cout<<"The maximum is: "<<num[4];
- 40. cout<<"Ascending Order: ";
- 41.
- 42. for(x=0;x<5;x++)
- 43.
- 44. cout<<num[x] << " ";
- 45.
- 46. for (x = 0; x <= 4; x++)
- 47. {
- 48.
- 49. for (int i = x + 1; i <= 4; i++)
- 50. {
- 51.
- 52. if (num[x] < num[i])
- 53. {
- 54.
- 55. temp = num[x];
- 56. num[x] = num[i];
- 57. num[i] = temp;
- 58. }
- 59. }
- 60. }
- 61. cout<<"Descending Order: ";
- 62. for(x=0;x<5;x++)
- 63. cout << num[x] << " ";
- 64. system(“pause”);
- 65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement