Small task in C language

Posts 1–3 of 3 · Page 1 of 1
Small task in C language


Can anyone help me with this?
I cant find a way to solve this...
Code:
#include <stdio.h>
#include <math.h>

double incr = 3;

double calculate(double start,double end) {
	if (start >= end) {
		return sqrt(end);
	}
	return sqrt(start + calculate(start+incr,end));
}

int main() {
	printf("%.*f\n",10, calculate(3,99));
	return 0;
}
Code:
#include <math.h>
#include <stdio.h>

int main()
{
    double val = 0;
    for (int i = 99; i >= 3; i -= 3)
    {
        val = sqrt(i + val);
    }
    
    printf("%g\n", val);
    return 0;
}
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us