int to float c

#include <stdio.h>

int main() {
    int integerNum = 10;
    float floatNum;

    floatNum = (float)integerNum;

    printf("Integer: %d\n", integerNum);
    printf("Float: %f\n", floatNum);

    return 0;
}

Explanation:

  1. Include the necessary header file stdio.h.
  2. Define the main() function.
  3. Declare an integer variable integerNum and initialize it with the value 10.
  4. Declare a floating-point variable floatNum without initialization.
  5. Convert the integerNum variable to a float using typecasting (float)integerNum. This converts the value of integerNum from an integer to a float.
  6. Print the original integer value using printf with the %d format specifier.
  7. Print the converted float value using printf with the %f format specifier.
  8. return 0; signifies the end of the main() function and the successful execution of the program.