Algorithm Analysis
Let's iterate through the elements of the array. We output the first element whose value does not exceed 2.5. If the required element is not found, we display the message “Not Found”.
Algorithm Implementation
Declare a working array.
double m[110];
Read the input data.
scanf("%d", &n); for (i = 1; i <= n; i++) scanf("%lf", &m[i]);
Iterate through the array elements.
for (i = 1; i <= n; i++) { // If m[i] is not more than 2.5, then we output the necessary information and end the program. if (m[i] <= 2.5) { printf("%d %.2lf\n", i, m[i]); return 0; } }
If the required element is not found, we display the message “Not Found”.
puts("Not Found");