WAP to print a value of x ,x = to a*a+b*b/2 in c++
Answers
Answered by
3
The given problem is solved using language - C++.
#include <iostream>
using namespace std;
int main(){
int a,b;
double x;
cout<<"Enter a: ";
cin>>a;
cout<<"Enter b: ";
cin>>b;
x=(a*a+b*b)/2.0;
cout<<"The value of x is: "<<x;
return 0;
}
- Accept first number, say a.
- Accept second number, say b.
- Declare and initialize x = (a² + b²)/2.
- Display the value of x.
See attachment for output.
Attachments:
Similar questions