Question: C PROGRAMING, POINTERS My code does not seem to work and i dont know how to fix it Write a function to split the integer

C PROGRAMING, POINTERS

My code does not seem to work and i dont know how to fix it

Write a function to split the integer and fractional part of a real number. call the function in main. void splitfloat( double x, int *intpart, double *fracpart ); Where x is the real number to be split (-10000 x<10000), * intpart and * fracpart are the integer part and fractional part of the real number x to be split respectively. [Example of input]: 4.118 [Sample output]: The integer part is 4 The fractional part is 0.118

My code:

#include void splitfloat( double x, int *intpart, double *fracpart ) { intpart = (int)x; fracpart = x - intpart; } int main(){ double x; scanf("%lf", &x); int *intpart; double *fracpart; splitfloat(x, intpart, fracpart); printf("The integer part is %d The fractional part is %0.3lf ", intpart, fracpart); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!