ADVERTISEMENT
ADVERTISEMENT

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

Rust | powf() function: Write a Rust program to calculate the power of float number using powf() function.
Submitted by Nidhi, on October 08, 2021

Problem Solution:

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.

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.

Rust Basic Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.