What is the problem does not print correct results | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

What is the problem does not print correct results

#include <iostream> using namespace std; int main() { double x = 2, y = 1, z = 3, i = 0, j = 0, l = 0, fact = 1, fac = 1, fa = 1, n, p; double eq = 0.0, sum = 0; cout << "Enter n : "; cin >> n; for (p = 0; p < n; p++) { for (i = 1; i <= x; i++) { fact *= i; } for (j = 1; j <= y; j++) { fac *= j; } for (l = 1; l <= z; l++) { fa *= l; } eq += ((fact + fac) / fa); x += 2; y += 2; z += 3; } cout << eq; return 0; }

27th Apr 2021, 11:55 PM
qais
qais - avatar
2 Respuestas
+ 3
tell us what you are making. your code excutes perfectly expect you didn't used the variable sum anywhere in your code after declaring it
28th Apr 2021, 12:12 AM
Rellot's screwdriver
Rellot's screwdriver - avatar
0
Coding Kitty I want to calculate the numbers multiplied and then collect and divide as indicated in the matter But I didn't get the right answers.
28th Apr 2021, 4:43 AM
qais
qais - avatar