So the question is
Write a function isqrt that consumes a non-negative integer n and produces the largest
integer less than or equal to the square root of n (that is, the integer square root of n).
To submit: isqrt.c, isqrt-driver.c.
and I've been working on this for about 2 days and getting nowhere.
for my isqrt.c I have
Code:
int isqrt(int n) {
int a = sqrt(n);
int b = 0
for (int i = 1; i <= a; i = i+1)
b = b +1;
return b;
}
for my isqrt-driver.c I have
Code:
#include <stdio.h>
#include <assert.h>
#include "isqrt.c"
int main()
{
printf("%d", isqrt(5));
assert(isqrt(5) == 2); /*no effect */
return 0;
}
I know this is my first program and all but I just don't understand what's wrong with what I'm doing...
Then I run the gcc -std=99 -O -o isqrt isqrt-driver.c isqrt.c
and it gives me a lot of error messages and
then run ./isqrt
and it says its not in the directory which makes sense cause it was never compiled.
Any help would be appreciated. Don't just give me code cause that is cheating and what not >.<. I'd ask my TA's but it is reading week so I don't have access to them