Hello, I am new to C and not really sure how to do this. This program extracts and prints the rightmost digit of the integer portion of a float, and I need to convert it but I'm not sure how.

#include <stdio.h>

void main (void)

 float num;
 int rightdigit;

 printf("Enter an integral number: ");
 scanf("%d", &num);

 rightdigit = num % 10;
 printf("\nThe right digit is: %d", rightdigit);


First of all, when you scanning float u should use %f

scanf("%f", &num);

I think u need an int operand to to use with %..
so cast the float to int with (int)

rightdigit = (int)num % 10;