Write a C program to perform math operations on two input whole numbers. The operations are:

Write a C program to perform math operations on two input whole numbers. The operations are:


a) Compute square root of n1
b) Compute square root of n2
c) Raise n1 to the power of n2
d) Inverse n1
e) Inverse n2


  1. //Write a C program to perform math operations on two input whole numbers. The operations are:
  2. //a) Compute square root of n1
  3. //b) Compute square root of n2
  4. //c) Raise n1 to the power of n2
  5. //d) Inverse n1
  6. //e) Inverse n2
  7. #include<iostream>
  8. #include<math.h>
  9. using namespace std;
  10. int main()
  11. {
  12.     int n1,n2;
  13.     cin>>n1>>n2;
  14.     cout<<sqrt(n1)<<endl;
  15.     cout<<sqrt(n2)<<endl;
  16.     int aux=n1;
  17.     for(int i=1;i<n2;i++)
  18.         aux=aux*n1;
  19.     cout<<aux<<endl;
  20.     aux=0;
  21.     while(n1>0)
  22.     {
  23.         aux=aux*10+n1%10;
  24.         n1=n1/10;
  25.     }
  26.     cout<<aux<<endl;
  27.     aux=0;
  28.     while(n2>0)
  29.     {
  30.         aux=aux*10+n2%10;
  31.         n2=n2/10;
  32.     }
  33.     cout<<aux<<endl;
  34. }


Learn More :