Previous Next
0 / 20
Module DEMO-32-89DEMO-C-32

Natural Logarithm

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Write a program that calculates the natural logarithm (base e) of a number using log.

Target difficulty: Easy

Constraints

x > 0

Input Format

A single positive floating-point number.

Output Format

The natural logarithm formatted to 2 decimal places.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
2.718
1.00
log(2.718) = 1.00
Sample #2
Public sample
10.0
2.30
log(10.0) = 2.30
Sample #3
Public sample
0.5
-0.69
log(0.5) = -0.69
Sample #4
Public sample
5.0
1.61
log(5.0) = 1.61

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings