0

What is the problem?

#include <iostream> using namespace std; int pow(int a ,int b) { int p=1,i; for(i=1;i<=b;i++) p=p*a; return p; } int f(int a,int b) { return pow(a,b)/pow(a+3*b,2); } int main() { int a,b; cin>>a>>b; cout<<f(a,b); return 0; }

27th Apr 2020, 12:22 PM
Amirhossein Omidi yekta
Amirhossein Omidi yekta - avatar
4 Réponses
+ 1
//so it should work #include <iostream> using namespace std; int pow(int a ,int b) { int p=1,i; for(i=1;i<=b;i++) p=p*a; return p; } double f(int a,int b) { return double(pow(a,b))/pow(a+3*b,2); } int main() { int a,b; cin>>a>>b; cout<<f(a,b); return 0; }
27th Apr 2020, 12:55 PM
Alexander Thiem
Alexander Thiem - avatar
0
There is no error ,answer is right enter inputs like this way 5 6
27th Apr 2020, 12:37 PM
Abhay
Abhay - avatar
0
add this to debug it and see the last result is 0. for(i=1;i<=b;i++){ p=p*a; cout << p <<endl; } what did you expect?
27th Apr 2020, 12:42 PM
Bahhaⵣ
Bahhaⵣ - avatar