Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Language%20in%20C%20Interview%20Questions%20and%20Answers

Question: Can we get the mantissa and exponent form of a given number?

Answer: The function frexp( ) splits the given number into a mantissa and exponent form. The function takes two arguments, the number to be converted as a double value and an int to store the exponent form. The function returns the mantissa part as a double value. Following example demonstrates the use of this function.

#include <math.h>
#include <stdio.h>

void main( )
{
double mantissa, number ;
int exponent ;

number = 8.0 ;
mantissa = frexp ( number, &exponent ) ;

printf ( "The number %lf is ", number ) ;
printf ( "%lf times two to the ", mantissa ) ;
printf ( "power of %dn", exponent ) ;

return 0 ;
}
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook