#include <iostream>
using namespace std;
int k=1;
int funsqrt(int p)
{
while (k * k <= p)
{
k++;
}
return k-1;
}
void displayRoots(int p)
{
for (k = 0; k <= p; k++)
{
cout << funsqrt(k) << " ";
}
}
int main(){
displayRoots(5);
return 0;}
//it cant display because the function is displayRoots not displayRoot.for it to work both the function and function call must be the same
// Non-incremental error to solve.initialize k oustside
Comments
Leave a comment