C++ Program to calculate a^2-b^2 | C++ Program to calculate 'a' square minus 'b' square. | C ++ प्रोग्राम 'a' स्क्वायर माइनस 'b' वर्ग की गणना करता है।






















C++ Program to calculate a2-b2.

Let see the program to calculate a2-b2.


Example:
  1. To calculate a2-b2.

  2. Formula: a2-b2=(a-b)*(a+b).

  3. Declare two variables they are integer data types a, b, and store
    the result in the result then declares an int data type.

  4. Declare one int data type and one float datatype, then store float data type.

  5. Declare two float data type, then store float data type.

  6. Declare two integer data types, then store int data type or float data type.

  7. Input a=2,b=3

  8. Then result=(a-b)(a+b)

  9. a2-b2 two numbers result =-5

#include <iostream> using namespace std; int main() { int a,b,result; cout<<"Enter a value :"; cin>>a; cout<<"Enter b value :"; cin>>b; result=(a-b)*(a+b); cout<<" a^2-b^2 of two numbers :"<<result<<endl; return 0; }
Output:
Enter a value :2 Enter b value :3 a^2+b^2 of two numbers:-5