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; }
2 Answers
+ 1
Add int d=0; before cout
if (a>b) {
b=a;
d=i;
}
0
Thank you