Ask coding questions

← Back to all posts
how to print the value of r
DexterDharmawan (0)

int root_finding_1(int n) {
for(int r = 0; r < 10000; r++) {
//hanya tepat jika n mempunyai akar bulat
if (r*r == n)

abc3354 (133)

Hi :)

You have a multiline if, you should use braces


if (r*r == n) 
cout <<r;<,endl;
return r; 


if (r*r == n) {
    cout << r << endl;
    return r;

(I fixed your cout)

Replit helper here !
If you found my answer helpful, you can upvote it :)