+ 2
What shall I code to get an output as (A+B) ²+(C+D)²
3 Réponses
+ 2
Sorry friend, I am new to C++ but I will keep trying to attempt to gain more knowledge of it.
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main() {
double a,b,c,d;
cin >> a;
cin >> b;
cin >> c;
cin >> d;
double e = 2;
double f = a + b;
double g = c + d;
double h = pow(f,e);
double i = pow(g,e);
cout << "(a + b) ^ 2 ="<< pow(f,e) << endl;
cout << "(c + d) ^ 2 =" << pow(g,e) << endl;
cout << "a =" << a << endl;
cout << "b =" << b << endl;
cout << "c =" << c << endl;
cout << "d =" << d << endl;
cout << "(a + b)^2 + (c + d)^2 =" << h + i << endl;
return 0;
}
I'm not getting how to input the values in the equation as output, if anybody else or you figured out please post.
+ 1
But I want it using the header file <math.h> and pow for power. Also the output should be displayed in terms of A, B, C and D.
+ 1
using math.h
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main();
{clrscr();
long a,b,c,d,e,f;
cout<<"Enter any four no.s. ";
cin>>a>>b>>c>>d;
e=a+b;
f=c+d;
cout<<"result is: "<<(pow (e, 2))+(pow (f, 2));
getch ();
}