![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
log1p() in C++ program
We are given with a variable of any type and the task is to find the result using the function log1p(). log1p() is an analytical function that takes an argument ‘a’ and also has a return value.
Syntax
double log1p (double x); Where x ranges between [-1, ?] float log1p (float x);
Return Type − This function returns a non-zero value if the argument is greater than -1 else it will return a non-numeric value.
Example
Input
a = 20.34
Output
3.06058
Input
a = 0.0
Output
0
Example
#include <cmath> #include <iostream> using namespace std; int main(){ double ans = 20.34; double temp; temp = log1p(ans); cout << "value of log1p(" << ans << ") is: "<<temp<< endl; ans = 0.0; temp = log1p(ans); cout << "value of log1p(" << ans << ") is: "<<temp<< endl; return 0; }
Output
value of log1p(20.34) is: 3.06058 value of log1p(0) is: 0
Advertisements