10. Write a C program void function that uses pointers to perform decompose operation. (Print only in the main function). Decompose means breaking up a decimal number into an integer part and a double part and storing them in different variables.

PHOTO EMBED

Wed Aug 09 2023 14:27:17 GMT+0000 (Coordinated Universal Time)

Saved by @Codes

// Online C compiler to run C program online
#include <stdio.h>

void decompose(double y, int *intpart,double *fract){
   *intpart = y;
   *fract = y - *intpart;
}

int main() {
    double pi = 3.142;
    int intpart;
    double fract;
    decompose(pi, &intpart, &fract);
    printf("%lf %d %lf", pi, intpart, fract);

    return 0;
}
content_copyCOPY