#include <stdio.h>


void splitfloat(float x, int *intpart, float *fracpart){
    
    *intpart = (int) x;
    
    *fracpart = x - *intpart;
    
}
                                                    


int main(void){
    float number = 1.662;
    int a;
    float b;
    
    splitfloat(number, &a, &b);
    
    printf("intpart = %d, fracpart = %f", a, b);

    
    return 0;
}

 

相关文章:

  • 2022-01-26
  • 2022-12-23
  • 2021-10-11
  • 2022-12-23
猜你喜欢
  • 2021-12-15
  • 2023-03-09
  • 2022-12-23
  • 2022-03-01
  • 2021-12-11
  • 2021-08-22
相关资源
相似解决方案