Q:

Rust program to calculate the power of float number using powf() function

belongs to collection: Rust Basic Programs

0

In this program, we will calculate the power of a floating-point number using the powf() function. Here we will use both the number and power of float type.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program/Source Code:

The source code to calculate the power of float number using the powf() function is given below. The given program is compiled and executed successfully.

// Rust program to calculate the power 
// of float number using powf() 
// function

fn main() 
{
    let num: f32 = 3.24;
    let result = num.powf(2.3);
    
    println!("Result is: {}", result);
}

Output:

Result is: 14.93666

Explanation:

Here, we created a variable num of f32 type with the initial value of 3.24. Then we calculated power 2.3 for the number num using the powf() function and printed the result.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Rust Basic Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Rust program to calculate the cube root of a numbe... >>
<< Rust program to calculate the power of float numbe...