0

What is wrong with the second “if “ part ?

#include <iostream> using namespace std; int main() { int a, b, c, d, r, s, n; cin >> n; while (cin >>a>>b>>c>>d){ s=b-a; r=b/a; if ( b==s+a && c==s+b && d==s+c) cout << a <<" "<< b <<" "<< c <<" "<< d << " " << d+s <<endl; if( b==a*r && c==b*r && d==c*r) cout << a << " "<<b << " "<< c << " "<< d << " "<< d*r <<endl; } return 0; }

19th Feb 2020, 6:30 AM
Hale Julieanne
Hale Julieanne - avatar
1 Réponse
+ 1
You must write what is wrong. C++ code is valid. The second if checks whether the entered data are elements of geometric progression.
19th Feb 2020, 7:13 AM
andriy kan
andriy kan - avatar