Question

Write c++ codes for the following mathmatical function : Square root Sin Ln

Write c++ codes for the following mathmatical function :
Square root
Sin
Ln
0 0
Add a comment Improve this question Transcribed image text
Answer #1

C++ supports many mathematical functions.All mathematical functions are defined in cmath library.

1)Square root

Sol) we have to use sqrt() function to  find square root of a number .

C++ Code :

#include <iostream>
#include <cmath>
using namespace std;
int main(){
   int n;
   cout << "Enter a number to find square root : ";
   cin >> n;
   cout << "Square root of " << n << " is " << sqrt(n);
}

Output :

2) sin function

Sol) We have to use sin() function to find the sin value of a number.

C++ Code :

#include <iostream>
#include <cmath>
using namespace std;
int main(){
   double n;
   cout << "Enter a number to find sin value : ";
   cin >> n;
   cout << "sin value of " << n << " is " << sin(n);
}

Output

3) ln

Sol) ln is nothing but natural logarithm.Using log() function we can calculate ln value.

C++ Code :

#include <iostream>
#include <cmath>
using namespace std;
int main(){
   double n, ln_value;
   n = 3.2;
    ln_value = log(n);
   cout << "log(" << n << ") = " << ln_value;
}

Output :

please up vote. Thank You.

Add a comment
Know the answer?
Add Answer to:
Write c++ codes for the following mathmatical function : Square root Sin Ln
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT