syntax error
Please resolve the error
@mohdkaifalam041,
Here is the correct code: https://ide.codingblocks.com/s/195939
You had to initialize the index variable, because the way the compiler sees it is, if this block of code:
if (sm > a[j]) {
sm = a[j];
c++;
index = j;
}
If its not executed, the value of index will be nothing and we have used it in our code below. So just initialize it with either 0 or -1 (Note: -1 can give out of bounds exception so be careful with that)
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.