code doesn't work with given numbers, but does with mine | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

code doesn't work with given numbers, but does with mine

Given: x=-3,265; y=25,333; z=0,447×10^-4, Result is s=1,10172 example: 2^(yx) + (3^x)^y - y*(arctgz - 1/3) / |x| - 1/y*y + 1 when x=1 y=2 z=3, the result matches with the calculator. When x=-3,265; y=25,333; z=0,447×10^-4, result is 2.582156 maybe I need to change the data type? #include <iostream> #include <stdio.h> #include <windows.h> #include <math.h> int main() { SetConsoleCP(1251); SetConsoleOutputCP(1251); float x, y, z, a, b, c, d, s; printf_s("Введіть x: "); scanf_s("%f", &x); printf_s("Введіть y: "); scanf_s("%f", &y); printf_s("Введіть z: "); scanf_s("%f", &z); // 1st a = pow(2, y * x); // 2nd b = pow(3, x * y); // numerator c = y * (atan(z) - 0.333); // denominator d = abs(x) + (1) / (y * y + 1); // all s = a + b - (c) / (d); printf_s("Результат s: =%f", s); return 0; }

19th Sep 2022, 5:43 PM
Андрей
Андрей - avatar
1 Answer
0
Variables overflowed. Pow(3, - 3265 * 25333) overflowed float type.
27th Oct 2022, 3:28 AM
Mohammad Reza Farzam
Mohammad Reza Farzam - avatar