I want to solve this problem :
link
#include <iostream>
using namespace std;
int luas, panjang, lebar, keliling;
int main() {
keliling = 0;
cin >> luas;
for (int i = 1; i <= luas; i++)
{
// cout << luas;
if (luas % i == 0)
{
panjang = luas / i;
lebar = i;
if ((panjang+lebar)*2 < keliling)
{
keliling = (panjang+lebar)*2;
}
}
}
cout << keliling;
}
I have done several experiments and what I can conclude is **keliling ** int value can be accessed in the inner if but cannot be updated. So the resulting output is not as expected. (whatever the input, the output will be 0)
3