0

Hello everyone, can anyone help me how to know location of the maximum number in this example

#include <iostream> using namespace std; int main() { int a; int b = 0; cout << "Enter 10 numbers\n"; for (int i = 0; i < 10; i++) { cout << " "; cin >> a; if (a > b) b = a; } cout << "The max:" << b << endl; cout << "The location of max:" <<b; return 0; }

11th May 2020, 5:21 PM
Dostonbek
Dostonbek - avatar
2 Antworten
+ 1
Add int d=0; before cout if (a>b) { b=a; d=i; }
11th May 2020, 5:37 PM
Igor Kostrikin
Igor Kostrikin - avatar
0
Thank you
11th May 2020, 5:57 PM
Dostonbek
Dostonbek - avatar