Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;//for cout and cin
- int main()
- {
- int a[5], greatest_so_far;
- cout << "Enter 5 numbers\n";
- for (int i = 0; i<5; i++)
- {
- cin >> a[i];
- }
- greatest_so_far = a[0];
- for (int i = 0; i < 5; i++)
- {
- if (a[i] > greatest_so_far)
- {
- greatest_so_far = a[i];//storing current greatest no.
- }
- }
- cout << "\nGreatest number is: " << greatest_so_far<<endl;
- system("pause");// to stop console window to see output
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement