The code works, but incorrectly, I can not understand what the error is. Here is the task: Let x0 = a; xk = qx(k–1) + b , ( k = 1, 2, ...) x0 = a; xk = qx(k–1) + b , ( k = 1, 2, ...) . Given a non-negative integer n , real a , b , c , d , q ( c < d ). Does xn belong to the interval ( c , d )?
Code:
#include<stdafx.h> #include<math.h> #include<cstdlib> #include<iostream> int main() { setlocale(LC_ALL, "Russian"); int n, k; float a, b, c, d, q; float x[100]; { printf("Введіть значення n: "); scanf_s("%lf", &n); printf("Введіть значення a,b,c,d,q: \n"); scanf_s("%i ", &a, &b, &c, &d, &q); x[0] = a; printf("x[0]= %5.1f\n", a); if (c > d); { printf("По умові c<d, введіть інші значення\n"); } if (c < d); for (k = 1; k <= 8; k++) { x[k] = q*x[(k - 1)] + b; scanf_s("x[%3f]= %5f", k, x[k]); } if ((c <= x[n]) && (d >= x[n])); printf("Хn належить інтервалу (c,d)"); else { printf("Хn не належить інтервалу (c,d)"); } } }